视频视图不播放 YouTube 视频 [英] Video View not playing youtube video

查看:32
本文介绍了视频视图不播放 YouTube 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在视频视图中播放 YouTube 视频.

I am trying to play a youtube video in a Video View.

我已经这样布置了 xml:

I have laid out the xml like this:

<VideoView 
            android:id="@+id/VideoView"
            android:layout_height="fill_parent"
            android:layout_width="fill_parent" 
            />

代码是这样的:

setContentView(R.layout.webview);
        VideoView vv = (VideoView) findViewById(R.id.VideoView);                        
        MediaController mc=new MediaController(this);
        mc.setEnabled(true);
        mc.show(0);
        vv.setMediaController(mc); 
        vv.setVideoURI(Uri.parse("http://www.youtube.com/watch?v=XS998HaGk9M"));
        vv.requestFocus();
        vv.showContextMenu();
        vv.start();  

我已在清单中添加了权限.当我加载应用程序时,会出现一个对话框,说明无法播放视频.

I have added the permission within the manifest. When I load the application a dialog appears stating the video cannot be played.

我将不胜感激.谢谢

推荐答案

虽然不是明确的答案,但我相信您需要使用 YouTube URL 启动意图并让操作系统处理它.也就是说,我不认为您可以将 YouTube 视频直接嵌入到您的活动中,尽管我很想被证明是错误的.

While not an explicit answer I believe you need to launch an intent with a YouTube URL and let the OS handle it. That is, I don't think you can embed YouTube videos directly into your activities though I would love to be proven wrong.

这篇关于视频视图不播放 YouTube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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