5

I am trying to play video through a webview on my Android and iPhone device. I would like the video to play and have some text displayed below it. Is it possible for me to play a video and not have the device switch into full-screen mode?

I am using the video tag in HTML5. My target platforms are iOS 5 and Android 2.1.

Collin Price
  • 5,620
  • 3
  • 33
  • 35

2 Answers2

3

android does not support inline-html5-video before version 3.1 - no chance before that. iOS 4+ does support it when you add this:

HTML

<video id="player" width="480" height="320" webkit-playsinline>

the important part is the added attribute webkit-playsinline. It is required for iPads to be able to play videos inline in the browser.

Obj-C

webview.allowsInlineMediaPlayback = YES;

The Obj-C code is required for iPhone/iPod. As of now they don't support inline video in the browser but with this line of code in your container-app it works in the webview

PS: copied the code-snippets from https://stackoverflow.com/a/3767927/818732

Community
  • 1
  • 1
Jörn Berkefeld
  • 2,540
  • 20
  • 31
0

You can simulate the playback by skimming the video instead of actually .play()'ing it, which is what starts the fullscreen.

I wrote a module that takes care of playing the video inline and synchronizing it to the audio (but it also works on videos without a sound track): iphone-inline-video

The iPhone and iPod now seem just about the only devices/browsers that force fullscreen video playback in Safari (and in apps that make use of its unmodified WebView). I couldn't find a recent Android device that would force the video fullscreen.

fregante
  • 29,050
  • 14
  • 119
  • 159