Created
September 1, 2012 08:18
-
-
Save amundo/3567064 to your computer and use it in GitHub Desktop.
playClip
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
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