Reputation: 641
I want to play a video in my Android app, and used the following code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showVideo();
}
private void showVideo()
{
VideoView vd = (VideoView)findViewById(R.id.videoview);
Uri uri = Uri.parse("android.resource://package/"+R.raw.movie);
MediaController mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.start();
}
Using this code, I am getting an error that the video can not be played.
Upvotes: 0
Views: 2117
Reputation: 3
You want to getPackageName, or provide it by hand to get it to work:
Uri uri=Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.movie);
Upvotes: 0
Reputation: 2036
Just a thought...should your URI really have "package" in the path? shouldn't you replace that with your actual application package: "com.whatever.something"?
Upvotes: 1