Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Shuffle Playlist Bug

4 replies [Last post]

Hey all,
So I have this weird bug whenever I try to shuffle an mp3 playlist. The shuffling works find, the code was from another user's post:

function shufflePlaylist()
{
     playlist = player.getPlaylist();
     var newplaylist = playlist;
     for(var rnd, tmp, i = newplaylist.length; i; rnd = parseInt(Math.random()*i), tmp = newplaylist[--i], newplaylist[i] = newplaylist[rnd], newplaylist[rnd] = tmp);

     player.sendEvent('LOAD', newplaylist);
};

Somehow, whenever I click the 'Shuffle' button, it shuffles fine, but whatever song was initially playing (because I have autostart set to true) now displays a duration in the playlist! And everytime I click 'Shuffle' while another song is playing that song now shows its duration in the newly-shuffled playlist. I looked at the generated XML playlist, and it doesn't have the duration anywhere written in it, and the code looks pretty safe, so I'm really at a lost. This isn't a big bug, but I'm just confused by it. Does anybody have any ideas?
Thanks!

Maybe you should stop the player before you shuffle the playlist.

function shufflePlaylist()
{
<strong>player.sendEvent('STOP');</strong>
playlist = player.getPlaylist();
var newplaylist = playlist;
for(var rnd, tmp, i = newplaylist.length; i; rnd = parseInt(Math.random()*i), tmp = newplaylist[--i], newplaylist[i] = newplaylist[rnd], newplaylist[rnd] = tmp);
player.sendEvent('LOAD', newplaylist);
};

*** EDIT ***

After a lot of testing, I can't reproduce this behavior.

When I shuffle while a track is playing, the duration always changes to the correct duration — JWMP-4.5.227.

Thanks for replying,

The bug isn't that it doesn't show the correct duration, it's that the playlist now shows a duration next to the sole file that was playing before I click shuffle. Does that make sense?

OK, so the incorrect duration is showing in the playlist display for the track that was playing before the shuffle.

Well... yu could modify the skin to not show the duration or put the correct duration in each track of your playlist.

There's some kind of a problem (I don't know the exact details) with AS3 not being able to get the MP3 duration from the Flash player immediately. The current workaround is to put the duration in the playlist.

Ok, thanks for the advice.