Last active
October 11, 2015 05:57
-
-
Save shinnn/3813231 to your computer and use it in GitHub Desktop.
goToChapter() Method on iTunes LP
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
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