Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Android 4.2 video playback restrictions
<!doctype html>
button {
display: block;
width: 100px;
height: 100px;
<video id="video" src="" width=300 height=150></video>
video = document.getElementById('video'),
button = document.getElementById('button'),
togglePlay = function() {
if (video.paused) {;
} else {
// this doesn't work. Android ~4.2 seems to want some sort of user interaction
// before playing a video
setTimeout(function() {; }, 2000);
document.addEventListener('click', function(e){
// this works. Android lets you trigger playback after a single timeout,
// unlike iOS
// ... but there is a limit. After a second timeout, videos can't be
// programmatically triggered anymore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.