YouTube的视频不能播放 [英] YouTube video doesn't play

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

问题描述

final String youtube = "<iframe class='youtube-player' type='text/html' width='200px' height='200px' src='http://www.youtube.com/embed/7vcc68CY9Rw' frameborder='0'>";

        webview = (WebView) findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setPluginsEnabled(true);
        webview.getSettings().setPluginState(PluginState.ON);


        webview.setWebViewClient(new WebViewClient() {

            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                dialog.show();
                return true;
            }

            public void onPageFinished(WebView view, String url) {
                if(dialog.isShowing()) {
                    dialog.dismiss();
                }
            }
        });

        webview.loadData(youtube,"text/html", "utf-8");

我不知道为什么YouTube视频不这里打球,也许我错过了写东西吗? web视图加载数据,但是当我preSS播放按钮,什么都没有发生在那里。有什么问题吗?

I don't know why youtube video doesn't play here, maybe I missed write something? The webview load the data but when I press play button nothing happened there. what is the problem here?

推荐答案

为什么不只是推出一个意图播放视频,然后让用户决定他们是否希望自己的preferred浏览器或YouTube应用来播放视频?当用户presses回来,他们将返回到您的应用程序。 (注意,这可能无法在模拟器工作)

Why not just launch an intent to play the video and then let the user decide if they want their preferred browser or the YouTube app to play the video? When the user presses back they will return to your app. (note this may not work on emulators)

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM")));

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

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