Question

I am building a SWF interface that plays specific segments of FLV videos on demand. When the user clicks on a specific button, the playhead goes to a predefined startValue.

vid1.playheadTime = startValue;
vid1.play();

This works fine, but sometimes it takes a long time for the video to go to the startValue, and I want to display a "Loading, please wait" message while this happens.

I tried using timers to check the current time of the playhead, and display a message (contained in loading_mc movieclip) if it is different from the playheadTime.

var myTimer:Timer = new Timer(100);
myTimer.addEventListener(TimerEvent.TIMER, video_ready);
myTimer.start();

function video_ready (e:TimerEvent):void{
    if (vid1.playheadTime != startValue){
      loading_mc.visible = true;
}
else { 
      myTimer.stop();
      vid1.play();
      loading_mc.visible = false;
} 

This works perfectly if I test it within Flash, but when tested in a browser, it often causes the SWF player to crash or, sometimes, the loading_mc clip does not go away. I also believe this might not be the most elegant solution. Any thoughts on an alternative way to deal with this?

Thanks a lot.

Was it helpful?

Solution

Just in case anyone stumbles upon a similar problem:

I found out the problem was in the format of the video, which prevented the player from seeking correctly through the video and wanted to fully load it before it could perform any seek functions. I converted the video to F4V and then the code above worked just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top