Navigation | Flash/Flex Video stops just before the end

Flash/Flex Video stops just before the end

I’m working on a flash/flex video app and have had some trouble with the videoDisplay component thinking that it has finished when infact it has stopped just before the end (like a frame or 2), it really wouldn’t matter particularly for my app having the video missing the last couple of frames, though the problem is when you’re waiting for the complete event. The complete event only seems to occur when the playheadTime is equal to the totalTime.

It doesn’t happen with all videos though the ones that have trouble have the trouble consistently. This can be confirmed by comparing myVid.playheadTime and myVid.totalTime. Fortunately the state of the video when the problem occurs will be “playing“, so my workaround is to set a timer to repeatedly check for a couple of things:

  1. That the state of the video is “playing” (myVid.state == “playing”).
  2. That the playheadtime is equal to the frame on the last check (myVid.playheadTime == lastFrame).
  3. That the playheadTime is not the same as the totalTime (myVid.playheadTime != myVid.totalTime).

In code:

if (myVid.state=="playing" && myVid.playheadTime == lastFrame && myVid.playheadTime != myVid.totalTime){
myVid.playheadTime = myVid.totalTime;
}
lastFrame = myVid.playheadTime;

A pity that I need to have a workaround like this though I wasn’t able to find anything else to fix the problem.

For those of you reading my blog that found this post completely useless as you have no interest in Flash/Flex you’ll hopefully like the end product :D

Filed by Popeye at December 2nd, 2007 under Flash, Flex, Actionscript 3

Leave a comment