I want to write the code which will play a video when a button is clicked. I can't get the video to display. When I click the button to play, the emulator stops working.
public class Video extends Activity{
private static final String MOVIE_URL = "http://www.youtube.com/watch?v=XtYzTxydKmk&list=PL33CD04942E3B59AF&index=3";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_layout);
VideoView video = (VideoView) findViewById(R.id.videoHK);
Uri HKvideo = Uri.parse(MOVIE_URL);
video.setMediaController(new MediaController(this));
video.setVideoURI(HKvideo);
video.start();
video.requestFocus();
}
For the button I have
Button videoButton = (Button) findViewById(R.id.btnVideo);
videoButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent video = new Intent(AboutHK.this, Video.class);
startActivity(video);
}
});