I am using jPlayer plugin. Here is an example link [ jsfiddle ]. I just want to start playlist from an individual track number, i mean if i have 5/10 tracks in a playlist then i want to start playlist from 2/5 track number at start.
Asked
Active
Viewed 73 times
1 Answers
1
You will need to modify a bit the play()
method in order to randomly selects the song to play.
Find below the code and this is an update to your fiddlejs
var myPlayer = new jPlayerPlaylist( /* give your params here as you were doing */);
// Clonning current play() method behavior
myPlayer._play = myPlayer.play;
// Modifying default behavior of current play() method which generates
// a random song index if not provided
myPlayer.play = function(songIdx){
if (!songIdx)
songIdx = Math.floor(Math.random() * this.playlist.length);
this._play(songIdx);
console.log('Playing song #', songIdx);
}

leo.fcx
- 6,137
- 2
- 21
- 37
-
Thanks bro excellent but can i add manually a number of track? @leo.fcx – userknowmore Jul 11 '15 at 21:13
-
Yes it is! ... see this updated jsfiddle (http://jsfiddle.net/leofcx/f05wxf1e/9/) ... if this was helpful please up-vote. – leo.fcx Jul 11 '15 at 21:30
-
Ok then i up-vote but i want to add manual track number without Math.floor/songIdx function please update @leo.fcx – userknowmore Jul 11 '15 at 21:48
-
The last jsfiddle that I provided (in previous comment) already has that change ... were you able to try it? – leo.fcx Jul 11 '15 at 21:53
-
yes but 1 problem is when i want to play 1 and click 2 time on botton then it play last one or randomly tracks – userknowmore Jul 11 '15 at 21:54
-
Oh I saw it ... please try this new one (http://jsfiddle.net/leofcx/f05wxf1e/10/) ... that was an edge case – leo.fcx Jul 11 '15 at 22:00
-
Thanks great @leo.fcx – userknowmore Jul 11 '15 at 22:01
-
Hi can you solve this question? http://stackoverflow.com/questions/31365538/how-to-save-current-playing-song-in-cookie @leo.fcx – userknowmore Jul 12 '15 at 07:42