Play Youtube HTML5 embedded Video in Android WebView

前端 未结 2 1472
旧巷少年郎
旧巷少年郎 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");
    
    0 讨论(0)
  • 2020-12-01 01:59

    Step 1 : Simply add this to Manifest file

    android:hardwareAccelerated="true"

    step 2 : check if you are setting layer for your webview.

    (i.e.) //myWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    setting hardware acceleration to true and commenting these lines worked for me .

    To know more about Hardware Acceleration and Layers look here at http://developer.android.com/guide/topics/graphics/hardware-accel.html

    0 讨论(0)
提交回复
热议问题