Skip to content

Instantly share code, notes, and snippets.

@shinnn
Last active October 11, 2015 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinnn/3813231 to your computer and use it in GitHub Desktop.
Save shinnn/3813231 to your computer and use it in GitHub Desktop.
goToChapter() Method on iTunes LP
iTunes.goToChapter = function(cNum){
//Note : iTunes.currentChapter starts at 1, NOT 0.
//If currently playing track has no chapter
if(this.currentChapter == 0 || ! cNum){
return;
}
var isPlaying = false;
if(this.waveform.waveformData){
isPlaying = true;
this.pause();
}
var diff = cNum - this.currentChapter;
if(diff > 0){
for(var i=0; i < diff; i++){
this.nextChapter();
}
}else{
for(var i=0; i >= diff; i--){
this.previousChapter();
}
}
if(isPlaying === true){
this.pause();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment