我尝试使用VideoView制作流视频应用但我收到错误无法播放此视频当我尝试从API获取网址时,这里是错误代码:
String url_video = vid.source_content;
但是当我手动添加网址(从API复制粘贴)时,视频可以很好地运行,这里是代码:
String url_video = "http://117.54.4.124:12180/mvicall/uploads/premium/Eli Sugigi - angkat sekarang juga.mp4";
这是我完整的videoView代码:
final TopArtis vid = getIntent().getParcelableExtra("video");
String url_video = vid.source_content;
// String url_video = "http://117.54.4.124:12180/mvicall/uploads/premium/Eli Sugigi - angkat sekarang juga.mp4";
mediaController = new MediaController(this);
mediaController.setAnchorView(mediaController);
Uri uri = Uri.parse(url_video);
videoview.setVideoURI(uri);
videoview.setMediaController(mediaController);
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
videoview.start();
}
});
videoview.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
return false;
}
});
答案 0 :(得分:1)
尝试调试您的代码,看看您通过Intent获取的URL是否是有效的URL。