Play Youtube HTML5 embedded Video in Android WebView

前端 未结 2 1475
旧巷少年郎
旧巷少年郎 2020-12-01 01:27

I am having a problem running a HTML5 Youtube embedded in a WebView. I want to play a Youtube video on my application. I

2条回答
  •  一整个雨季
    2020-12-01 01:57

    EDIT

    So from the comment conversation we have deducted:

    On this website: www.youtube.com/html5 it says you have to sign in then opt in for HTML5 video playback

    That is why your video will not load, it is redirecting to a flash version and your webview does not have flash.

    ORIGINAL

    Are you overriding url loading so your webview is being used?

     wv.setWebViewClient(new WebViewClient(){
                        @Override
                        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                                return false;
                        }
                });
    

    Are you saying the video won't play but the website loads?

    You could try lying to YouTube and telling them your a different browser (perhaps pretend to be the android browser) Firefox is:

     wv.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.36 (KHTML, like Gecko) Chrome/13.0.766.0 Safari/534.36");
    

提交回复
热议问题