Cutthroat_Trout
asked on
Event Listener for end of a FLV
I am trying to use Actionscript 3.0 to listen for the end of a video, and then go to a label created on the timeline. Can anyone provide an example of this?
blue-genie, that code is for the AS2 component.
If you are using the AS3 FLVPlayback component the event syntax is slightly different:
(assuming your playback component has the variable name flvPlaybackComponent)
import fl.video.VideoEvent;
flvPlaybackComponent.addEv entListene r(VideoEve nt.COMPLET E, listenerFunction);
function listenerFunction(e:VideoEv ent):void
{
//what ever code you wanted to do onComplete
trace(e.target) // FLVPlayback object
}
If you are using the AS3 flash.media.Video class and calling the Video.attachNetStream() method, (which I recommend, its more efficient) Let me know and I'll post the solution for that.
If you are using the AS3 FLVPlayback component the event syntax is slightly different:
(assuming your playback component has the variable name flvPlaybackComponent)
import fl.video.VideoEvent;
flvPlaybackComponent.addEv
function listenerFunction(e:VideoEv
{
//what ever code you wanted to do onComplete
trace(e.target) // FLVPlayback object
}
If you are using the AS3 flash.media.Video class and calling the Video.attachNetStream() method, (which I recommend, its more efficient) Let me know and I'll post the solution for that.
ahh sorry, shoud read carefully, thanks for putting me right.
ASKER
Can you please post the solution for streaming video?
sure, (sorry for the delay over the long weekend)
Assumptions:
You have a NetStream named stream and a NetConnection named connection
Other notes:
Notice the MovieClip(stage).gotoAndPl ay / gotoAndStop, assuming you want to access a frame label on your main timeline this may or may not be necessary depending on where you are putting the code. (i.e in a document class vs. inline on a layer). There is no _root in AS3 and the stage is a DisplayObjectContainer, thus does not have the property gotoAndPlay unless you cast it as a MovieClip
Assumptions:
You have a NetStream named stream and a NetConnection named connection
Other notes:
Notice the MovieClip(stage).gotoAndPl
var stream:NetStream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
private function netStatusHandler(e:Event):void
{
switch( event.info.code )
{
//you can track other events here as well from the stream such as
//case "NetStream.Play.StreamNotFound"
//or case "NetStream.Play.Switch"
//the property fired on complete is NetStream.Play.Complete so:
case "NetStream.Play.Complete:
//on complete code here
MovieClip(stage).gotoAndStop(frame);
//or MovieClip(stage).gotoAndPlay(frame)
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i found this online at kirupa.
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.complete = function():Void {
_root.gotoAndPlay("yourfra
trace(this);
};
my_FLVPlybk.addEventListen
try it and see.
blu