Created
February 19, 2014 16:50
-
-
Save brycemcd/9096137 to your computer and use it in GitHub Desktop.
Playing around with the HTML5 audio/video controls
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
// Load up an mp3 in a FF address bar. | |
// in the browser. Don't let it autoplay. | |
// in FF, the mp3 loads in a video player. Create a var to reference the video player: | |
var v = document.getElementsByTagName("video")[0]; | |
// set the playhead at 0 and then play: | |
v.currentTime = 0; | |
v.pause(); | |
//Speed functions: | |
function speedUp() { | |
v.playbackRate = 2.5; | |
} | |
function normalSpeed() { | |
v.playbackRate = 1; | |
} | |
function slowDown() { | |
v.playbackRate = 0.5; | |
} | |
//missed it. go back 10 seconds | |
function goBackTen() { | |
v.pause(); | |
v.currentTime = v.currentTime - 10; | |
v.play(); | |
} | |
function loopForTen() { | |
goBackTen(); | |
setTimeout(function() { | |
goBackTen(); | |
}, 10000); | |
} | |
// play around in the console: | |
// start playback: | |
// v.play(); | |
// speed it up: | |
// speedUp(); | |
// ok, that was too fast, slow mo please | |
// slowDown(); | |
// normalSpeed(); | |
// loop over 10 second chunks | |
// loopFor10(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment