3

I'm trying to build a basic video player with a playlist using the OVP Player. So far I have figured out how to feed in the new video source using ExternalInterface, but I can not figure out how to listen for the Flash event "EVENT_END_OF_ITEM".

How do I listen for Flash events in Javascript (and thus jQuery)?

OVP has a lot of events defined, but I don't know how to listen for them. For example, here is the EVENT_END_OF_ITEM:

public function endOfItem():void {
     sendEvent(EVENT_END_OF_ITEM);
}

The OVP documentation is non-existent and their support forum is almost as bad.

Drew Baker
  • 14,154
  • 15
  • 58
  • 97

3 Answers3

4

In the Model.as file find add this line in with all the other imports (at the start of the file):

import flash.external.*;

Then in the end event, add this line:

ExternalInterface.call("stopedPlaying");

So that an event would look like this:

        public function endOfItem():void {
            sendEvent(EVENT_END_OF_ITEM);
            // inform JavaScript that the FLV has stopped playing
            ExternalInterface.call("stoppedPlaying");
        }

Then in your the HTML document, add this between SCRIPT tags:

function stoppedPlaying()
{
    // do something when the FLV starts playing
};
Drew Baker
  • 14,154
  • 15
  • 58
  • 97
  • I wrote more on how to solve this here: http://stackoverflow.com/questions/4189442/jquerythis-and-externalinterface/4197115#4197115 – Drew Baker Nov 16 '10 at 17:51
1

I think that externalInterface plugin for jQuery will make it relatively easy. If not then there's DOMEx class which looks promising. Code example from DOMEx site:

if (ExternalInterface.available) ExternalInterface.call(javaScript, "Howdy Ya'll");
[...]
hjhndr
  • 68
  • 5
0

you can use SWF object project google
http://code.google.com/p/swfobject/

This library gives you the capability to listen events from actionscript to javascript and is very simple to use

Geraud Mathe
  • 711
  • 2
  • 9
  • 20
  • As far as I can tell, it only lets you listen to "Flash has finished loading" events, not specific events from within the SWF. – Drew Baker Nov 17 '10 at 17:19