I implemented a flex application to play an incoming video stream from a Red5 Media Server.
private function playStream(streamName:String, offset:int):void {
stream = new NetStream(connection);
stream.play(streamName + ".flv", offset);
var streamVideo:Video = new Video();
streamVideo.attachNetStream(stream);
display.addChild(streamVideo); }
The playStream method plays a given stream from the position which is defined by offset parameter. Now I want to update my page content depending on the played video stream. Or more specifically I want to call an actionscript method that updates the content, after each minute in the video. Should I use Timer for that reason?
Best regards
Yes, you will need to user a Timer
object. But don't use the Timer
to determine where the user is at in playback of the video. You should use the time property of the NetStream
instead.
You should also add an event listener for the NetStatusEvent
in your playStream()
method. In particular, you want to inspect the info property of this event (technically it's the info.code
property). This has several useful messages that you will want to use to know: when the video playback starts/stops/pauses, when the user performs a seek, and so on. This way you can manage your Timer
and update the UI efficiently when the user interacts w/the video player.
Some of the relevant codes on the NetStatusEvent
are below. But inspect the full list, you might find others that will help you.