我正在嘗試使用MediaView使用videoView播放音頻。音頻播放良好,當我點擊返回鍵控制返回到以前的狀態。但是當我從啓動屏幕再次選擇活動時,活動會顯示,但音樂不會播放。任何人都可以幫我解決這個問題嗎? 的代碼如下:提前點擊返回鍵並返回Android中的活動後音樂不播放
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video);
videoView = (VideoView)this.findViewById(R.id.videoView);
videoView.setVideoPath("http://www.pocketjourney.com/downloads/pj/video/famous.3gp");
final MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://www.pocketjourney.com/downloads/pj/tutorials/audio.mp3"));
videoView.requestFocus();
videoView.start();
videoView.setMediaController(new MediaController(this)
{
public void hide()
{
System.out.println("HIDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEHELLLOO");
mc.show();
}
});
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
感謝