Yevgeny Simkin
Yevgeny Simkin

Reputation: 28379

What's different between using WebView and Browser for YouTube Video api?

I've implemented the youtube api and it works as expected in a regular computer browser. When I test it in both Ice Cream Sandwich and Gingerbread, on the stock Browser (which is Webkit) it also works exactly as it does on my computer.

However, when I load it into a WebView it experiences some very odd behavior. Specifically, it loads all the player controls (play button, progress bar, etc) and fires all the normal events for buffering and playing, but then rather than playing, it just skips to the end and displays the standard YouTube post-playback icons for other videos. If I click on one of those icons, it then skips that video and jumps straight to the end of that video.

I have setJavascriptEnabled and setPluginsEnabled both set to true. I assume I'm missing something, since it all works fine in the stock browser, but I'm stumped as to what it is. Has anyone implemented the YouTube Video player (or JWPlayer, or anything with which I can play youtube videos) in a WebView? And if so, please share how you managed to get it to work.

TIA

[EDIT] Since posting this, I've implemented a native player that retrieves video streams directly from YouTube. This is INCREDIBLY clunky because the fragmentation between devices relating to which files they can/cannot play is *really huge, and since there's no way to pass YouTube a device model and have it return the relevant streams, what happens is that you get all the streams and then have to pick from the array. Anyway... the point is that this is just a dreadful approach and I'd really love to figure out the good ole' embedded player solution, since it *must work, given that it works in the stock browser. Could this be a headers issue?

Upvotes: 18

Views: 4109

Answers (2)

BoD
BoD

Reputation: 11045

Have you tried this by any chance: http://code.google.com/p/html5webview/source/browse/trunk/HTML5WebView/src/org/itri/html5webview/HTML5WebView.java

Basically the tag doesn't work on a 'default' WebView without some complicated and not really documented configuration. Please tell us if that fixes your problems.

Please also see this issue: http://code.google.com/p/android/issues/detail?id=22254

Upvotes: 2

Somnath Muluk
Somnath Muluk

Reputation: 57776

I don't know much about android. But go through following links which can be useful for you.

WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored. If your goal is only to display some HTML as a part of your UI, this is probably fine; the user won't need to interact with the web page beyond reading it, and the web page won't need to interact with the user. If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView,browser view is more customised for small screen.

  1. http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application
  2. How to play a video in a webview with android?
  3. UIWebView to Play Local and downloaded Video
  4. Android play youtube video in webview
  5. Video streaming using RTSP: Android

Upvotes: 0

Related Questions