Android WebView Responsive Youtube not playing

ε祈祈猫儿з 提交于 2019-12-08 07:54:37

问题


I have a very basic WebActivity that serves up a page that has the styling of

CSS

.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
}

.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

Next, edit add some HTML around your embed code.
HTML

<div class="video-container"><iframe width="853" height="480" src="https://www.youtube.com/embed/xxxxxx" frameborder="0" allowfullscreen</iframe</div>

If I view this page with the browser on the device, the page loads and the video plays just fine.

However if I use a webview programmed into my app, and load the page,clicking on the like, I get a message on the youtube video window (after the loading spinner) of "An error occurred. Please try again later (Playback ID: xxxxxx) Learn More"

of which learn more does not display anything useful. Idea's on how to go about seeing what is going on? The Android Studio logcat is not displaying any issues?


回答1:


so it turns out that there are a few more params needed to play embeded iframe videos from YouTube.

Had to add the following to the end of the url string

src="https://www.youtube.com/embed/xxxxxxxxx?version=3&enablejsapi=1"



来源:https://stackoverflow.com/questions/46671454/android-webview-responsive-youtube-not-playing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!