Skip to content

Instantly share code, notes, and snippets.

@amundo
Created September 1, 2012 08:18
Show Gist options
  • Save amundo/3567064 to your computer and use it in GitHub Desktop.
Save amundo/3567064 to your computer and use it in GitHub Desktop.
playClip
HTMLAudioElement.prototype.playClip = function(startTime, stopTime) {
var video = this;
var playTime = stopTime - startTime;
this.currentTime = startTime;
setTimeout(function(){ video.pause() }, playTime * 1000);
this.play();
}
var audio = document.querySelectorAll('audio')[0]; // assume this is a reference to an audio file
// now you can do:
audio.playClip('52.893', '53.286'); // and it should play just that bit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment