Android WebView Responsive Youtube not playing

Issue

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? Image of playback error

Solution

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?version3&enablejsapi1″

Answered By – justdan0227

Leave a Comment