Skip to content

Instantly share code, notes, and snippets.

@brycemcd
Created February 19, 2014 16:50
Show Gist options
  • Save brycemcd/9096137 to your computer and use it in GitHub Desktop.
Save brycemcd/9096137 to your computer and use it in GitHub Desktop.
Playing around with the HTML5 audio/video controls
// 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