Closing a video in (prettyphoto) lightbox, on a timer? Looking for simple javascript

Hey everybody, I had a code I found on google a few weeks ago that did this function well, but as I redesigned a few parts I deleted the code, and I cannot find it again :\

The one thing I didn’t like about the code was that the timer was not set in minuets or seconds it was set in hundreds ex. 800 would be equivalent to IDK I would have to guess and it wasn’t very accurate.

Ex. of the lightbox and video to give you a better picture can be found here: www.VisumDesignz.com the second slideshow image has a play button on it click that and the video will appear in a prettyphoto lightbox.

I am sure you guys know a code for this by heart or you are better at keyword searches than me because I cannot find it on google :slight_smile:

Thanks in advance.

i think its set to millisecond so 800 means 8 seconds.

It would be 0.8 seconds :wink:

Visumdesignz: AFAIK all timing functions in javascript are done in Milliseconds

With regards to closing the lightbox when the video finishes playing, the optimal solution would be achieved if the videoplayer would allow you to register a callback so that it can run some JavaScript once it finishes.

(One player that I regularly use, JW Player, has [URL=“http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/17249/detecting-playback-completion”]functionality like this built in, perhaps your player has something similar?)

I am not even using a player, it’s just a .swf file I styled the light box to fit around the .swf. I think I should get some type of player though.

If you made the flash file yourself, you could use an ExternalInterface.call to call some JS on your page, that will allow you know when it’s finished playing and close the lightbox.

Assuming you’re using ActionScript3, you could do something along these lines:

//call this when your video/flash/animation finishes
ExternalInterface.call("playbackFinished");

With the following JavaScript:

function playbackFinished() {
    //do your magic in here
}