0

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?

SeanPONeil
  • 3,901
  • 4
  • 29
  • 42

1 Answers1

2

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.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • Worked like a charm. The youtube link though is youtube.com/watch?v=videocode and the thumbnail link is http://img.youtube.com/vi/videode. I accepted your answer but you should edit the answer – SeanPONeil Sep 22 '11 at 21:54
  • 1
    Ok thanks, edited. I think YouTube might have changed link format along the years. – Mikko Ohtamaa Sep 23 '11 at 17:31
  • Actually, a complete list of proper links to YouTube video thumbnails can be seen at http://stackoverflow.com/questions/2068344/how-to-get-thumbnail-of-youtube-video-link-using-youtube-api – Giulio Piancastelli Jun 06 '12 at 09:19