Android Mediaplayer在播放带有视频视图的youtube视频时引发错误 [英] Android Mediaplayer throws an error while playing a youtube video with video view

查看:140
本文介绍了Android Mediaplayer在播放带有视频视图的youtube视频时引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在视频视图中播放网址的代码

Here is the code for playing a url with vedio view

String urlVideo = "http://www.youtube.com/cp/vjVQa1PpcFPLrLo9hkR90zKx_XHP5kMNaNb-_bE3v0s=";
    VideoView video = (VideoView) findViewById(R.id.videoView1);
    Log.d("You", urlVideo);
    video.setVideoURI(Uri.parse(urlVideo));
    MediaController mc = new MediaController(this);
    video.setMediaController(mc);
    video.requestFocus();
    video.start();
    mc.show();

它抛出错误,无法开始播放视频

It throws error and can not start the video

这是日志消息

 ERROR/MediaPlayer(1765): error (1, -2147483648)

ERROR/MediaPlayer(1765):错误(1,-2147483648) DEBUG/VideoView(1765):错误:1,-2147483648

ERROR/MediaPlayer(1765): Error (1,-2147483648) DEBUG/VideoView(1765): Error: 1,-2147483648

  1. 模拟器和目标操作系统为2.2.
  2. 这已在模拟器上进行了测试.

此代码可以在设备上正常运行吗? 您能解释一下错误代码和错误背后的原因吗?

Can this code run properly on device?? Can you explain the error code and reason behind the error??

编辑:非常感谢您的建议.实际上,我的应用程序需要按照自己的设计播放视频,并且根据您的建议和我在网络上看到的一些其他帖子,可以得出结论,该视频无法按照我想要的方式进行播放,因此我必须在网络上打开它看法.谢谢...

Edit : Well thanks all for your suggesions. Actually my application needs to play a video in its own design and according to your suggesions and some other post I have seen on web it can be concluded that it can not be played on the way I desire and I have to open it in a web view. Thanks...

推荐答案

确切的错误代码是 MEDIA_ERROR_UNKNOWN (未知错误,在这里很有帮助).

The exact error code is MEDIA_ERROR_UNKNOWN (Unknown error...very helpful here).

失败的原因是您正在使用的链接直接转到Flash视频. VideoView不支持Flash,因为Dianne简洁地将其放在发布 ...

The reason it is failing is the link you are using goes directly to a Flash video. Flash is not supported in VideoView, as Dianne so succinctly puts in this post...

显示视频的最佳方法可能是将其打包为Intent,然后让浏览器或YouTube应用播放.如果用户还有其他支持Flash的应用程序(例如Skyfire),则该应用程序也应显示在选项中.但是,这通常仅与视频的观看链接配合使用,因此 http://www.youtube. com/watch?v = fX_wt7cPCU4 .

The best way for you to show that video is probably to package it up in an Intent and let either the Browser or the YouTube app play it. If the user has some other Flash-enabled app like Skyfire, it should show up in the choices as well. However, this usually only works with the watch link for a video, so http://www.youtube.com/watch?v=fX_wt7cPCU4 in your case.

String videoUrl = "http://www.youtube.com/watch?v=fX_wt7cPCU4";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(videoUrl));
startActivity(Intent.createChooser(intent, "Play Video Using");

在安装了YouTube应用的设备上,这是一个选项,尽管由于某些原因并非所有YouTube视频都可以在移动应用中播放.

On a device with the YouTube app installed this will come up as an option, although not all YouTube videos can play in the mobile app for some reason.

希望有帮助!

这篇关于Android Mediaplayer在播放带有视频视图的youtube视频时引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆