I am curious if anyone knows of a way I can set my .SWF external FLV player to call a JavaScript function once the flv is ready/buffered for playback? Everything I have tried thus far has not worked...Any help would be greatly appreciated!
+2
A:
If you're using the FLVPlayback class , you need to listen to the fl.video.VideoEvent.READY
Edit// Make sure to set the following in your embed code
param name="allowScriptAccess" value="always"
Edit//
you're probably using the FLVPlayback component in Flash CS , this component should have an instance name, so try to add this code at the same level , replacing "flvInstanceName" with the instance name of your FLV component. if your FLVPlayback component is on the main timeline, just add a Layer, in the first frame create a blank keyframe and add this code.
Try to run the swf , when the video is ready to play, you should have a trace statement. If you do , then you just have to set up your JS function
import flash.external.ExternalInterface; flvInstanceName.addEventListener(VideoEvent.READY , videoReadyListener); private function videoReadyListener(event:VideoEvent):void { ExternalInterface.call("nameOfJSFunction"); trace( event ); removeEventListener(VideoEvent.READY , videoReadyListener ); }
PatrickS
2010-08-20 17:52:23
I am using the FLVPlayback component--where would I place this code?
Squirkle
2010-08-20 18:44:37
As mentioned above, create a Layer , add a keyframe and place this code. This should be at the same level with your FLVPlayback component
PatrickS
2010-08-20 18:50:14
This returns an error: the private attribute may only be used on class property definitions...
Squirkle
2010-08-20 19:21:19
sorry, force of habit , i'm usually working with classes, remove the private attribute , just write: function videoReadyListener
PatrickS
2010-08-21 03:25:18
Still returns an error...
Squirkle
2010-08-25 16:10:37
can you tell me what error is returned
PatrickS
2010-08-25 16:37:04