Click to See Complete Forum and Search --> : how to find length or set position (in time) of a flash movie from Javascript?
AnilPhilip
06-03-2008, 08:25 AM
how to find length or set position (in time) of a flash movie from Javascript?
I am trying to control the Flash player from Javascript.
- I need to set the start position to play, based on time.
example, setPosition(10 seconds)
However I notice that the flash player API is based upon number of frames.
for example, the methods TotalFrames() and GotoFrame() are based on frame number.
How do I convert it to time? (I don't see a frame length variable).
- I also need a callback into my Javascript object when an event occurs - for example,
when the player stops playing because it is stopped by the user. Should work on earlier
versions than Flash 8.
Any help appreciated.
thanks,
Anil
Eye for Video
06-04-2008, 01:59 AM
Well I may not exactly have your answer but I’m pretty sure you need to consider the frame rate to calculate your time. So for example, a Flash .swf file with a frame rate of 15 fps would be at frame 150 in 10 seconds. Yet the same .swf playing at 24 fps would reach 10 seconds in 240 frames.
I’ve had to use this method when calculating jumping into the middle (or any section) of a .swf to synchronize video and audio.
http://www.citradingcards.com/multimedia/new_citc_ad.htm
While the video is running at an exact frame rate, I had to calculate the audio to the 1000th of a second, or something like that for the number of frames that the video (at whatever frame rate) had played.
Sorry I don’t have the ActionScript for that but I just can’t find it.
The key is to know your frame rate… then do the math.
Eye for Video
www.cidigitalmedia.com
AnilPhilip
06-04-2008, 09:54 AM
Thanks for replying.
Yes, I figured I must know the frame rate. But how do you get that?
I haven't been able to find the answer.
clip duration = FlashPlayer.TotalFrames() / frame rate
Here is an article by someone who says he is on the Flash Player team - but there is no mention of how to get the frame rate
http://www.kaourantin.net/2006/05/frame-rates-in-flash-player.html
-
Anil
Well I may not exactly have your answer but I’m pretty sure you need to consider the frame rate to calculate your time. So for example, a Flash .swf file with a frame rate of 15 fps would be at frame 150 in 10 seconds. Yet the same .swf playing at 24 fps would reach 10 seconds in 240 frames.
I’ve had to use this method when calculating jumping into the middle (or any section) of a .swf to synchronize video and audio.
http://www.citradingcards.com/multimedia/new_citc_ad.htm
While the video is running at an exact frame rate, I had to calculate the audio to the 1000th of a second, or something like that for the number of frames that the video (at whatever frame rate) had played.
Sorry I don’t have the ActionScript for that but I just can’t find it.
The key is to know your frame rate… then do the math.
Eye for Video
www.cidigitalmedia.com