Struggling with this problem for a few days in a row now...
Is there any way or 'hack' to disable playing video fullscreen on Safari on a iPhone. Of course I already tried the 'webkit-playsinline' attribute, but this will only work in your own app.
See:
<video class="" poster="" webkit-playsinline> <source src="" type="video/ogg" preload="auto"> <source src="" type="video/mp4" preload="auto"> </video>
Also I've tried to put the video on canvas, but as it looks video as a source for the canvas drawImage() method is not currently supported on iOS.
Is there any other way or alternative technique I can use? Or did I really waste my time the last few days?
Tap the video you'd like to watch. At the bottom of the video player, tap full screen or swipe up on the video.
Exit full screenAt the bottom-right of the video player, click full screen exit . Or double-click the video.
Apple finally enabled the attribute playsinline
in all browsers on iOS 10, so this will work seamlessly:
<video src="file.mp4" playsinline>
You can work around this issue by simulating the playback by skimming the video instead of actually .play()
'ing it.
In short, use iphone-inline-video, it takes care of the playback and audio sync (if any), and it keeps the <video>
working as it should.
<div id="video-player"> <video src="http://movies.apple.com/media/us/html5/showcase/2011/demos/apple-html5-demo-tron-us_848x352.m4v"></video> <p><a href="javascript:playPause();">Play/Pause</a></p> </div> <script type="text/javascript"> // intercept and cancel requests for the context menu var myVideo = document.querySelector('video'); myVideo.addEventListener("contextmenu", function (e) { e.preventDefault(); e.stopPropagation(); }, false); // hide the controls if they're visible if (myVideo.hasAttribute("controls")) { myVideo.removeAttribute("controls") } // play/pause functionality function playPause() { if (myVideo.paused) myVideo.play(); else myVideo.pause(); } // essentially you'll have to build your own controls ui // for position, audio, etc. </script>
The idea is to:
The downside is that you have to implement your own player UI - but it's not too complicated
*This code is only intended to show you how to solve the problem, not for use in a live application
A bit more research on the subject finds:
webkit-playsinline Indicates that a video element should play in-line instead of full-screen.
Related Tags “video” Availability Available in iOS 4.0 and later. (Enabled only in a UIWebView with the allowsInlineMediaPlayback property set to YES. source
I'm afraid it just not going to be possible using the video player in Safari
They have a guide for Video on Canvas, but as you probably know it isn't supported in IOS yet: video on canvas
This document summarises the current restrictions around mobile media content in IOS: mobile video status
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With