Playing HTML5 video on fullscreen in android webview

后端 未结 8 2207
迷失自我
迷失自我 2020-11-22 10:23

Well, I\'ve been searching few days already, how to display HTML5 video in full-screen mode on android WebView.

I managed to play HTML5 videos on my webview. Problem

8条回答
  •  执笔经年
    2020-11-22 10:44

    It seems that in lollipop and up (or maybe just a different WebView Version) that calling cprcrack's onHideCustomView() method does not work. It works if it is called from the exit fullscreen button but when you specifically call the method it will only exit fullscreen but the webView stays blank. A way around it is to simply add these lines of code to onHideCustomView():

    String js = "javascript:";
    js += "var _ytrp_html5_video = document.getElementsByTagName('video')[0];";
    js += "_ytrp_html5_video.webkitExitFullscreen();";
    webView.loadUrl(js);
    

    This will notify the webView that fullscreen has exited.

提交回复
热议问题