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

Forums

/

JS callbacks

1 reply [Last post]

I've had a couple of issues (mainly with loading a playlist) that my code instantly tries to move onto the next command before the playlist has loaded. i.e.

player.sendEvent("LOAD", 'nextPlaylist');
player.sendEvent("PLAY");

I've had to put a timeout around the PLAY command, but this doesn't feel like a very nice fix to me. It'd be better if I could parse in a function that triggers once the playList has loaded. It might look something like:

player.sendEvent("LOAD", 'nextPlaylist', function(){
     player.sendEvent("PLAY");
});

I guess the only other way I could do it, is to create an array from an AJAX request to the same playlist file and parse that in (and use a callback on that function) but that seems like a convoluted path to take.
Any suggestions?

Use the PLAYLIST Listener. It will be called when the playlist load is complete. You might still need a 100ms delay though, but at least you can be sure that the playlist has been loaded and indexed into an object, etc.

http://developer.longtailvideo.com/trac/wiki/FlashEvents#PLAYLIST