Bachalo
Bachalo

Reputation: 7219

AS3 StageVideo, how to determine when ended?

Using this SimpleStageVideo wrapper for an AS3 AIR videoplayer.

http://www.bytearray.org/?p=2571

I need to determine when the video has ended but can see no events that are triggered.

Can anyone suggest a workaround?

Upvotes: 1

Views: 201

Answers (1)

BadFeelingAboutThis
BadFeelingAboutThis

Reputation: 14406

StageVideo and Video both use NetStream (which is the actual video content). That is where you listen for events related to the content.

So if you're currently playing a video using the component you link to, you should already have a NetStream object.

Here is an example:

var stream:NetStream = ...//your net stream object you should already have to play the video, assumption here is you already have it instantiated.

stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler,false,0,true);

function netStatusHandler(event:NetStatusEvent):void {
    switch (event.info.code) {
        case "NetStream.Play.StreamNotFound":
            //the video wasn't found, better tell the user something
            break;

        case "NetStream.Play.Start":
            //video started playing
            break;

        case "NetStream.Play.Stop":
            videoFinishedHandler(); //do something now that the video is finished playing
            break;
    }
} 

If you want to see a list of all the other NetStream Status events you can intercept, see the documentation

Upvotes: 1

Related Questions