我有這樣的方法,用於播放視頻:Videoview不玩視頻
private void changeVideoState() {
playing = !playing;
if (playing) {
videoView.start();
play.setVisibility(View.GONE);
stop.setVisibility(View.VISIBLE);
} else {
videoView.stopPlayback();
stop.setVisibility(View.GONE);
play.setVisibility(View.VISIBLE);
}
}
在第一時間調用方法時視頻已被播放。
但任何其他時間,當我嘗試撥打videoView.start()
沒有任何反應。
這裏是videoview的初始化:
videoView = (VideoView) findViewById(R.id.preview);
MediaController mc = new MediaController(getActivity());
// mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.fromFile(file));
是否顯示任何錯誤? – ridoy