我需要在自己的WebView玩手机Youtube视频 [英] What I need to play mobile youtube videos in my own webview

查看:217
本文介绍了我需要在自己的WebView玩手机Youtube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是很简单的,我已经阅读pretty很了解,但还是失败了。

The problem is quite simple, and I have read pretty much about it, but still failed.

我要使用移动版YouTube(而不是桌面版)从YouTube播放视频,但如果是我的问题,我不能播放视频,它只是加载并没有什么happend。

I want to use mobile youtube (not desktop version) to play videos from youtube, but where is my problem, that I can't play video it just "loading" and nothing happend.

我不希望回旋处及开视频在YouTube应用,还是在桌面网站播放视频。

I don't want roundabouts and open videos in youtube app, or play videos in desktop site.

我只希望在我自己的WebView功能齐全m.youtube.com。

I just want fully functional m.youtube.com in my own webview.

请给我一些想法!

推荐答案

请尝试通过如下贴膜在Web视图中的HTML内容打在你的WebView的你管的视频:

Please try playing the You tube video in your webview by laoding the HTML content in your web view as follows:

 public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            WebView wv1 = (WebView) findViewById(R.id.webView1);
            wv1.getSettings().setJavaScriptEnabled(true);
            wv1.getSettings().setPluginsEnabled(true);
            final String mimeType = "text/html";
            final String encoding = "UTF-8";
            String html = createHTML();
    wv.setWebChromeClient(new WebChromeClient() {
    });
            wv1.loadDataWithBaseURL("", html, mimeType, encoding, "");
        }

        public String createHTML() {
            String html = "<iframe class=\"youtube-player\" style=\"border: 0; width: 100%; height: 95%; padding:0px; margin:0px\" id=\"ytplayer\" type=\"text/html\" src=\"http://www.youtube.com/embed/"
                    + "E2fB5XWj7IE"
                    + "?fs=0\" frameborder=\"0\">\n"
                    + "</iframe>\n";
            return html;
        }

和你需要有硬件加速你的应用程序了开机..
给它一个镜头,让我知道。

And you need to have hardware acceleration turned on in your applicaiton.. give it a shot and let me know.

这篇关于我需要在自己的WebView玩手机Youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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