Update: (Old Answer No Longer Applicable)
Use the iphone-inline-video JS module. You can get your 360 videos to play inline (without having to pin to home screen).
I have attempted to update the docs for that module so that it demonstrates how to use Aframe with iOS here.
Here's the source for completeness (your video MUST be local, see below):
<!DOCTYPE html>
<!-- Source: https://github.com/aframevr/aframe/blob/v0.3.2/examples/boilerplate/360-video/index.html -->
<html>
<head>
<meta charset="utf-8">
<title>Aframe 360 Video with iOS Support</title>
<meta name="description" content="360 Video — A-Frame">
<style>
#playoverlay { position: relative; }
#play-button {
position: absolute;
bottom: 30px;
left: 30px;
}
/* Hide native iOS controls */
.IIV::-webkit-media-controls-play-button,
.IIV::-webkit-media-controls-start-playback-button {
opacity: 0;
pointer-events: none;
width: 5px;
}
</style>
</head>
<body>
<a-scene>
<a-assets>
<video id="video" src="sample.mp4" autoplay loop crossorigin playsinline></video>
</a-assets>
<a-videosphere src="#video" rotation="0 180 0"></a-videosphere>
</a-scene>
<div id="playoverlay">
<button id="play-button">Play / Pause</button>
</div>
<script src="https://aframe.io/aframe/dist/aframe.js"></script>
<script src="../dist/iphone-inline-video.browser.js"></script>
<script>
(function() {
var video = document.querySelector('#video');
window.makeVideoPlayableInline(video, /* mute necessary for autoplay*/ false);
var playButton = document.querySelector('#play-button');
playButton.addEventListener('click', function(e) {
if (video.paused) {
video.play();
} else {
video.pause();
}
});
})();
</script>
</body>
</html>
iOS/Mobile Safari Caveats:
On iOS
the video source MUST be local (iOS/Safari seems to be the ONLY major browser that has CORS issues with video src
, AND (depending on software/hardware), the video might need to be under a certain resolution. For example, to support iPhone 5, I found I couldn't play any videos larger than 1920x1080, YMMV...
Other considerations:
- Controlling audio via controls for your 360 video is a no-go. The volume on iOS Safari is read-only (see here).
- Safari on iOS does NOT allow for gyroscopic/sensor detection in iFrames - so make sure your video is not embedded anywhere else if you want the gyroscope/accelerometor to work (see here), so your iOS users won't get any of the nice movement control that A-Frame provides for free.
- iOS/Safari does NOT support full-screen (
iOS Safari doesn't have a fullscreen API, but we do on Chrome on Android, Firefox, and IE 11+
), ref here. The argument that "Safari supports full screen in videos" ONLY works when it falls back to its native player (in which case the 360 video texture that A-Frame/Three.js wrap around a canvas sphere does not work because you have a flat 360 video that looks awful).
Getting videos (in my case 360 degree videos) to play on iOS has been quite a challenge, but is possible with a TON of concessions.