views:

34

answers:

1

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
I am using the FLVPlayback component--where would I place this code?
Squirkle
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
This returns an error: the private attribute may only be used on class property definitions...
Squirkle
sorry, force of habit , i'm usually working with classes, remove the private attribute , just write: function videoReadyListener
PatrickS
Still returns an error...
Squirkle
can you tell me what error is returned
PatrickS