1

I have an FLEX application where I need to know if the LIVE stream on FMS exists when I do a NetStream.play(); Example:

var stream = new NetStream(nc);
stream.play("streamnotexists");

How can I pick the error on play how are trying to play a tream that not exists ?

rizidoro
  • 13,073
  • 18
  • 59
  • 86

2 Answers2

-1

You need to write a listener function on your netstream, for status type event. As a status you get NetStream.Play.StreamNotFound . Refer to this and this for further understanding.

Harit K
  • 358
  • 1
  • 3
-1

You should add a listener to your NetStream object, like so:

stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

where netStatusHandler is:

function netStatusHandler(event:NetStatusEvent):void {
            switch (event.info.code) {
                // some other cases
                case "NetStream.Play.StreamNotFound":
                    trace("Unable to locate vod stream: " + videoURL);
                    break;
                case "NetStream.Play.UnpublishNotify":
                    trace("Unable to locate live stream: "+ videoURL);
                // rest of the cases, default, etc
            }
        }

The complete list of event.info.code can be found here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/NetStatusEvent.html but be aware that only the events that begin in NetStream. are triggered by the NetStream object.

evilpenguin
  • 5,448
  • 6
  • 41
  • 49