views:

605

answers:

3

Is there a way to detect end of Flash movie (OOTB, without using some sort of flash callback).

Alternatively, is there a way to know the length of the movie?

Update:

IsPlaying() looked promising (periodically checking it), but as it turns out, nobody is creating straight forward swfs any more; now, the content is embedded in main layer and while the content plays, the main movie is stopped and IsPlaying is always false...

A: 
var movie = window.document.movie

if(movie.TCurrentFrame("/") == movie.TotalFrames())
    alert("Movie Finished");

or you could have:

if (!movie.IsPlaying())
    alert("Movie Stopped");

but thats not really what you're after.

Ambrosia
A: 
import fl.video.VideoEvent.COMPLETE
video.addEventListener(VideoEvent.COMPLETE, alertHTML);

function alertHTML(e:VideoEvent):void{
    ExternalInterface.call("alert(\"Video has stopped\");");
}

Give that a shot. You can replace the alert(\"Video has stopped\"); with your client-side javascript function.

rson
This is actionscript right? I was hoping to do it with javascript (so I don't have to bother our flash developers)
Luc
A: 

You can chceck for movie length with ffmpeg -i movie.flv 2>&1, but i doesnt' tell you:

  • how long it takes to load the video and start playing
  • whether the user has hit the "pause" button.

Right now, the only way is to attach some javascript handlers to Flash events as other posts suggest.

hegemon
I was a bit unclear in my question. I meant .swf kind of Flash movie not .fla one.
Luc