Can I avoid the native fullscreen video player with HTML5 on iPhone or android?
In iOS 10+
Apple enabled the attribute playsinline
in all browsers on iOS 10, so this works seamlessly:
<video src="file.mp4" playsinline>
In iOS 8 and iOS 9
Short answer: use iphone-inline-video, it enables inline playback and syncs the audio.
Long answer: You can work around this issue by simulating the playback by skimming the video instead of actually .play()
'ing it.
There's a property that enables/disables in line media playback in the iOS web browser (if you were writing a native app, it would be the allowsInlineMediaPlayback
property of a UIWebView). By default on iPhone this is set to NO
, but on iPad it's set to YES
.
Fortunately for you, you can also adjust this behaviour in HTML as follows:
<video id="myVideo" width="280" height="140" webkit-playsinline>
...that should hopefully sort it out for you. I don't know if it will work on your Android devices. It's a webkit property, so it might. Worth a go, anyway.
Old answer (applicable till 2016)
Here's an Apple developer link that explicitly says that -
on iPhone and iPod touch, which are small screen devices, "Video is NOT presented within the Web Page"
Safari Device-Specific Considerations
Your options:
- The
webkit-playsinline
attribute works for HTML5 videos on iOS but only when you save the webpage to your home screen as a webapp - Not if opened a page in Safari - For a native app with a WebView (or a hybrid app with HTML, CSS, JS) the
UIWebView
allows to play the video inline, but only if you set theallowsInlineMediaPlayback
property for theUIWebView
class to true