How to embed a YouTube clip in a WebView on Android

后端 未结 3 830
庸人自扰
庸人自扰 2020-11-30 10:19

Can anyone shed any light on why I\'m unable to click and play a youtube clip on an Android handset when placed inside a webview?

I\'ve put a very simple app togethe

相关标签:
3条回答
  • I am not sure if this is what you need. Anyway I hope the following be useful. You can use the iframe method that youtube provides to play its videos. If the browser supports html5 will show the video with it, otherwise with flash.

    You can use the following code as an example <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/bIPcobKMB94" frameborder="0">

    in the above example the video id is bIPcobKMB94. You can change this id and show your video.

    You can access a live example of it here

    More infromation for youtube iframe

    YouTube HTML5 Video Player

    0 讨论(0)
  • 2020-11-30 10:52

    Unless the user has Froyo this is going to be impossible. However as long as the user has the YouTube app installed (which is standard for most phones I believe) then you can include a link to the YouTube video, and Android will recognize it as such and open it using the YouTube app. It's not as elegant as embedding, but it's much more reliable.

    0 讨论(0)
  • 2020-11-30 10:57

    You would need to have the flash player, which is only available since Android 2.2 (Froyo).

    0 讨论(0)
提交回复
热议问题