0

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!

Squirkle
  • 933
  • 1
  • 7
  • 22

1 Answers1

2

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
  • 9,539
  • 2
  • 27
  • 31
  • I am using the FLVPlayback component--where would I place this code? – Squirkle Aug 20 '10 at 18:44
  • 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 Aug 20 '10 at 18:50
  • This returns an error: the private attribute may only be used on class property definitions... – Squirkle Aug 20 '10 at 19:21
  • sorry, force of habit , i'm usually working with classes, remove the private attribute , just write: function videoReadyListener – PatrickS Aug 21 '10 at 03:25