Last active
November 11, 2022 03:46
-
-
Save speir-wang/b43f38b467a5d66b56073ea7cd08831a to your computer and use it in GitHub Desktop.
Avoid the HTML5 video play button being displayed automatically on iPhone when the Low Power mode is turned on.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let videoBackground = document.getElementById("video-background"); | |
var promise = videoBackground.play(); | |
if (promise !== undefined) { | |
promise | |
.catch(error => { | |
// Auto-play was prevented | |
// Show a UI element to let the user manually start playback | |
console.log(error); | |
}) | |
.then(() => { | |
// if there is no error, then we play the video | |
videoBackground.play(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
did not work for me