Skip to main content
Known Participant
March 18, 2011
Answered

When video ends go to timeline label

  • March 18, 2011
  • 1 reply
  • 814 views

Hi Everyone

I am using this code to play a video when a user clicks on a button:

function clicked(event:MouseEvent):void {

var video:Video = new Video();

addChild(video);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

ns.client = {onMetaData:ns_onMetaData, onCuePoint:ns_onCuePoint};

video.attachNetStream(ns);

ns.play("video.flv");

function ns_onMetaData(item:Object):void {

trace("metaData");

video.width = item.width;

video.height = item.height;

video.x = (stage.stageWidth - video.width) / 2;

video.y = (stage.stageHeight - video.height) / 2;

}

}

When the video ends I want to go to another part of the timeline. How can I do this?

Hope someone can help!

Many thanks!

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

"I thought NetStream.Play.Stop is also fired when the user stops the playback?"

Yes, it does. But it is up to developer to let user stop the playback or not via API.

FLVPlayback can be used but it is way too heavy (and is an overkill in my opinion) and although it is not a bad point to start with video - ultimately if one want full control - using native AS3 video streaming framework is more compact and manageable.


IIRC NetStream.Play.Stop is also fired when the playback is stopped during buffering.

1 reply

Kenneth Kawamoto
Community Expert
Community Expert
March 18, 2011

There is onPlayStatus "event" for NetStream you can use the same way as others in your ns.client object. NetStream.Play.Complete is the property you would react to.

Inspiring
March 18, 2011

As for onPlayStatus - it works with streaming video but not progressive (yours is progressive).

To implement what you need  - listen to NetStatusEvent on NetStream instance --> do what you need when event's info property is "NetStream.Play.Stop".

Read mor about this event:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/NetStatusEvent.html

Kenneth Kawamoto
Community Expert
Community Expert
March 18, 2011

I thought NetStream.Play.Stop is also fired when the user stops the playback? If so that itself cannot tell you if the stream reached the end.

The other approach is to use FLVPlayback and listen to fl.video.VideoEvent.COMPLETE event. Especially if it's progressive there's no need to use NetStream.