Android WebView with embedded YouTube video does not have a full-screen button

I am trying to add a small embedded video to YouTube. The user should be able to view the full screen video, but the YouTube web browser does not have a full screen button! Whhhaa ...? I searched around and did not find a solution. BTW using the Google YouTube API is NOT an option. I have a workaround (a video thumbnail that opens a fullscreen WebView when clicked), but it would be much simpler / more elegant if the webview would handle this for me.

This is how I upload youtube video

 String htmlString = "<html><body style='margin:0px auto; padding:0px; width: 100%;'><script type='text/javascript' src='http://m.youtube.com/iframe_api'></script><div style=\"padding-bottom: 56.25%;position: relative;\"><iframe allowfullscreen='allowfullscreen' id='playerId' type='text/html' style=\"width: 100%; height: 100%; position: absolute;\" width=\"560\" height=\"315\" src='http://www.youtube.com/embed/IwfUnkBfdZ4?enablejsapi=1&rel=0&playsinline=0&autoplay=0' frameborder='0'></div></body></html>";
        if (youtubeWebView == null){
            youtubeWebView = ButterKnife.findById(view, R.id.youtubeWebview);
        }
        youtubeWebView.getSettings().setJavaScriptEnabled(true);
        youtubeWebView.getSettings().setLoadWithOverviewMode(true);
        youtubeWebView.loadData(htmlString, "text/html", null);
+4
source share

Source: https://habr.com/ru/post/1584340/


All Articles