Performing an action when the video is complete
December 23rd, 2007 . by polyGeekIt’s pretty simple to perform some action when a video completes playing. You use the videoMaruCreationComplete function to set a callback - videoMaru.setOnVideoComplete( fn ) - to some function that you would like to run when your video finishes playing.
Here is a simple example that is fully commented. Hopefully you can follow this template to do what ever you need to do.
| Download Example FLA |
Here is the code that enables this. You’ll need to look inside the FLA to understand the layer structure and read the comments.
function videoMaruCreationComplete():Void {
videoMaru.setOnVideoComplete( theVideoIsOver );
}
//
function theVideoIsOver():Void {
this._parent._parent.gotoAndStop( "videoOver" );
}








hi
i hav a flv player, inside a html page,
in html page one button is there,
that button should be invisible until user click & watch half of the flv movie(suppose it reach to a particular cue point),
after reaching particular cue point,that html button should be automatically active,
any idea how to do this type of thing using javascript in flash,plz provide the code for that
neeraj8585@gmail.com
Hi, excellent video implementation!
Bit of an issue with the setOnVideoComplete with some FLVs that are compliled using premier, it just refuses to work, could you spread any light on this?
Ta
@Mark, I’m pretty sure it has to do with the metaData that’s received - which doesn’t seem to be correct when exporting with Premier. I’m working on a solution in the next version that will work without the metaData.
The latest flash players support H264 (Quicktime-) movies. Since the quality/file size is much better I did some experimenting with these files in videoMaru. Most functions seem to work perfectly (did I say what a wonderful job you have done?). The only problems I found are in the functions that appear to use keyframes (”back#” and “timeline”. But “setOnVideoComplete” also does not respond. Does it also use keyframes? (tried versions up to 3.5b). And, more important, is there a solution?
Thanks,
Arjen
@Arjen, I’m happy that videoMaru will even play H264. I had no idea. Thanks for telling me.
I do remember that getting the onVideoComplete to work was a real challenge with FMS. I can’t remember exactly what I did but it was a bit of a hack.
Fortunately, for me, I no longer have the Flash IDE installed so I can’t even look at the code for videoMaru. The source code is here on the site to download and poke around with. Sorry I can’t help. Good luck!
Hi Dan,
Thanks for your swift reply. Since I only stumled upon videoMaru a couple of days ago I never realized you stopped working on it. No problem, time for someone else to pick up where you left.
I looked through your source code which only made me realize I have a long way to go in Flash before I can even begin to understand what to do…
Still, I did find some code related to netstream(?) and as far as I understand it this is only used in flash video and not in Quicktime. Maybe some day I’ll try to rework this part into checking if timeRemaining is null. Since the duration and everything related to it (timeR, timeC etc) works this might work.
For now I’ll simply stick to flv or f4v (also works with videoMaru and recognizes videoComplete). F4v also supports H264 as a compressor, just have to find decent compression software. Adobes Media Encoder is very blurry and changes colors much more than Quicktime. Anyway, thanks for all your work and good luck with all your other projects.
Arjen
@Arjen, I hope you’re able to work out your needs with videoMaru.