SeanPONeil
SeanPONeil

Reputation: 3910

Embedded Youtube videos in a WebView

I would like to be able to display Youtube videos in a WebView but not play them in the WebView, rather send an intent to the dedicated Youtube app and play the video there. Ideally the Youtube video would be displayed as an image with a play button similar to the way iOS handles Youtube videos.

How would I go about handling this?

Upvotes: 0

Views: 1878

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83676

Youtube provides thumbnails for all videos.

If my memory serves me correctly you can figure out the thumbnail image URL based on the actual YouTube URL.

Then just add this thumbnail on your app page:

 <a href=youtube.com/watch?v=videocode>
    <img src=img.youtube.com/vi/videode>
 </a>

When URL pattern matches to youtube.com Android will automatically suggest opening it in an app.

For play button overlay, just use CSS, position relative and add another on the top of the thumbnail.

Upvotes: 2

Related Questions