views:

563

answers:

2

I'm looking for a way to find the status of a live stream through a VideoDisplay (or any other method really). I am interested to know if the stream is currently being published to or if the publisher has stopped. This is for a Flex/Flash ActionScript 3 project.

Is there a way to do this or is this ANOTHER oversight by adobe?

flex flash adobe adobe-flex actionscript

A: 

I've only found one solution, and that's using the NetStream object in combination with a video control.

The video control must be manually added to an

nsListen = new NetStream(nc);
nsListen.addEventListener(NetStatusEvent.NET_STATUS, nsListenHandler);
nsListen.play(streamname);

var v:Video = new Video();
v.attachStream(nsListen);
uicontrol.add(v);

Finally, the event status is returned in nsListenHandler:

private function nsListenHandler(e:Event):void
{
    if(e is NetStatusEvent)
    {
     var nse:NetStatusEvent = NetStatusEvent(e);
     if(nse.info.code == "NetStream.Play.Failed")
     {
      // Big error.

     }
     if(nse.info.code == "NetStream.Play.PublishNotify")
     {
      // Stream has just been published

     }
     if(nse.info.code == "NetStream.Play.UnpublishNotify")
     {
      // Stream has just been unpublished

     }
     trace(NetStatusEvent(e).info.code);
     trace(NetStatusEvent(e).info.description);
    }
}

Only this code wont do is tell you if a stream is already successfully being published to.

vanja.
A: 

You can dig into NetStatusEvent events.

Check this live docs