views:

654

answers:

4

Hi all, In my android app I have a WebView to display html data from our website. Sometimes the page will have youtube embed objects. This doesn't show up properly in the app. Is there any way to show/play youtube videos in WebView ? Thanks.

+1  A: 

You cannot show them embedded except perhaps on devices that have Flash.

However, if you can parse out the YouTube video details, you may be able to construct an ACTION_VIEW Intent that will show them on the YouTube application...for those Android devices that have the YouTube application.

You might also experiment with HTML5's <video> tag, which AFAIK is supported in the Browser application and may therefore work in WebView.

CommonsWare
thanks Mark, Im going with starting a new intent on the youtube url.
Ionic Walrus
A: 

You could try switching your website to embed the HTML5 version of the YouTube player instead of the flash version. Still not sure this will work 100%, but it's obviously going to work better than the flash version on devices that don't currently support flash.

Edit: Nevermind it looks like the HTML5 version also requires the browser to support the H.264 codec, which it doesn't look like any Android devices currently support.

mbaird
+3  A: 

Read my post on the android-developers group here: YouTube in the emulator?

Basically, the best way to play YouTube clips is to create your own Activity for it, and here's a great example: Polish Your App: Free Embeddable Android YouTube Activity!

Felix
Thanks Felix, I looked at having a custom player but decided against it. The reason is the default player has more features such as bookmark, starring etc that won't be available on the custom player. Also the default player is more familiar to the user.
Ionic Walrus
A: 

Hi,

I tried HTML5 tags in android but those tags are not working in my application. is HTML5 tags are working in android ?

Jetti