Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Commit

Permalink
Actually stop autoplay on iOS 10
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jun 8, 2017
1 parent 4955468 commit 508ec53
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,25 @@ export default function enableInlineVideo(video, opts = {}) {
}
}

// Stop native playback
if (!video.paused && video.webkitDisplayingFullscreen) {
video.pause();
}
// Try to pause
video.pause();

// Prevent autoplay.
// An non-started autoplaying video can't be .pause()'d
const willAutoplay = video.autoplay;
video.autoplay = false;

addPlayer(video, !video.muted);
overloadAPI(video);
video.classList.add('IIV');

// Autoplay
if (video.muted && video.autoplay) {
if (video.muted && willAutoplay) {
video.play();
video.addEventListener('playing', function restoreAutoplay() {
video.autoplay = true;
video.removeEventListener('playing', restoreAutoplay);
});
}

if (!/iPhone|iPod|iPad/.test(navigator.platform)) {
Expand Down

0 comments on commit 508ec53

Please sign in to comment.