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...

6 comments:

  1. Hey Justin,

    Did you ever find a better workaround for this issue?

    ReplyDelete
  2. I haven't. I would recommend searching the Phonegap Group: http://groups.google.com/group/phonegap?pli=1

    ReplyDelete
  3. phonegap 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?

    ReplyDelete
  4. It looks like there's a fix here:

    https://groups.google.com/forum/#!topic/phonegap/boMH5X2FfN0

    ReplyDelete
  5. look there, I posted an working example based on fixed aVideo plugin

    http://stackoverflow.com/questions/5467678/does-phonegap-have-a-video-player/7527821#7527821

    ReplyDelete
  6. in AppDelegate.m try something like this:


    /**
    * 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;
    }

    ReplyDelete