HTML5的Video和VideoView有什么区别?为什么我这段代码有错误呢?


我尝试在VideoView中通过WebView播放视频, 但VideoView一直不工作,我捕获了下错误
"Sorry, this video cannot be played."

下面是这段代码,请大家帮忙分析一下错误的根源在哪里?:

   
  public class VideoHandler extends Activity {
  

WebView myWebView;
VideoView myVideoView;
WebChromeClient chromeClient;
WebViewClient wvClient;
Intent in;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);

myVideoView = (VideoView) findViewById(R.id.videoview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(myVideoView);
String video = (MNWVMainPage.myWebView.getUrl());
myVideoView.setMediaController(mediaController);
myVideoView.setVideoPath(video);
myVideoView.start();

myVideoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.release();
setContentView(R.layout.mnwv_main);
}
});
}
}

java html5 php HTML

菟原手奈儿 12 years, 7 months ago

你看错误提示的是视频文件不能播放,就有2个种可能,videoview不支持这种格式,还有就是播放链接错误,你通过webview得到的url你决定是正确的能够播放的地址么,检查一下吧

爷是三季稻 answered 12 years, 7 months ago

Your Answer