Created
July 19, 2012 19:34
-
-
Save 4rn0/3146246 to your computer and use it in GitHub Desktop.
Trigger fullscreen HTML5 video on iPad
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Trigger fullscreen HTML5 video on iPad</title> | |
<style> | |
#video { height: 1px; opacity: 0; position: absolute; width: 1px; } | |
#play { width: 100px; } | |
</style> | |
</head> | |
<body> | |
<video src="http://82.201.53.54:1935/livestream/iphone538.sdp/playlist.m3u8" id="video"></video> | |
<button id="play">play fullscreen video</button> | |
<script> | |
var video = document.getElementById('video'), | |
play = document.getElementById('play'), | |
time; | |
video.addEventListener('webkitbeginfullscreen', function() { | |
play.innerText = 'play fullscreen video'; | |
window.clearInterval(time); | |
}); | |
video.addEventListener('webkitendfullscreen', function() { | |
video.pause(); | |
}); | |
play.addEventListener('touchstart', function() { | |
time = window.setInterval(function() { | |
try { | |
video.webkitEnterFullscreen(); | |
} | |
catch(e) {} | |
}, 250); | |
play.innerText = 'loading ...'; | |
video.play(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is working very well & helped me to implement the same effect in all the devices ๐ ๐