Reputation: 15
I want to play a video from a url in a VideoView:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
String path1="http://commonsware.com/misc/test2.3gp";
Uri uri=Uri.parse(path1);
VideoView video=(VideoView)findViewById(R.id.videoView1);
video.setVideoURI(uri);
video.start();
}
But I'm getting a NullPointerException when I try to run the app.
The logcat says that the problem is in: video.setVideoURI(uri);
Can someone help me please?
Thanks.
Upvotes: 0
Views: 4201
Reputation: 86948
I don't see where you are defining a layout... I think you forgot:
setContentView(R.layout.main);
Which would cause any findViewById() to return null.
Upvotes: 1