A collection of handy code snippets in the languages that I use on a daily basis.
November 30, 2010
Android: Phonegap issue with HTML5 video
We've been trying to implement HTML5 video inside a WebView in an Android Phonegap app, and there's a big difference between the embedded web browser and the native web browser on the Samsung Galaxy Tab (and likely other Android devices). In the native browser, an HTML5 <video> player will pop the video into the native media player, and should play fine if you've used an appropriate codec, and jumped through the right hoops. But, in an embedded browser in a Phonegap app, the video won't play at all. We resorted to using an <a> link with a _blank target to pop you completely out of the app. This was the only solution we could come up with. It's a pretty sad story dealing with the "standards" of HTML5 video across all the platforms and browsers that supposedly support it. I'm not sure there's a good way to deal with all of the different platforms/scenarios...
Subscribe to:
Post Comments (Atom)
Hey Justin,
ReplyDeleteDid you ever find a better workaround for this issue?
I haven't. I would recommend searching the Phonegap Group: http://groups.google.com/group/phonegap?pli=1
ReplyDeletephonegap in iphone can use html5 video to play video,but in android can't do it, so I use a tag to open browser play video。 have better method?
ReplyDeleteIt looks like there's a fix here:
ReplyDeletehttps://groups.google.com/forum/#!topic/phonegap/boMH5X2FfN0
look there, I posted an working example based on fixed aVideo plugin
ReplyDeletehttp://stackoverflow.com/questions/5467678/does-phonegap-have-a-video-player/7527821#7527821
in AppDelegate.m try something like this:
ReplyDelete/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
*/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
BOOL ok = [super application:application didFinishLaunchingWithOptions:launchOptions];
if (ok) {
self.webView.allowsInlineMediaPlayback = YES;
self.webView.mediaPlaybackRequiresUserAction = NO;
}
return ok;
}