我想编写在单击按钮时播放视频的代码。我无法显示视频。当我单击按钮播放时,模拟器停止工作。
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();
}
对于我有的按钮
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);
}
});