Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting end of Flash movie in javascript

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...

like image 452
Luc Avatar asked Nov 18 '09 10:11

Luc


2 Answers

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.

like image 66
SimonDever Avatar answered Oct 29 '22 21:10

SimonDever


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.

like image 40
rson Avatar answered Oct 29 '22 21:10

rson