Skip to main content
August 17, 2006
Question

Stream.prototype.onStatus problem

  • August 17, 2006
  • 2 replies
  • 374 views
Is it not possible to use Stream.prototype.onStatus in main.asc to add an event handler for all Stream instances? I've added this code

Stream.prototype.onStatus=function(info)
{
trace("Stream.onStatus(): level="+info.level+" code="+info.code);
}

to main.asc but the method is never invoked even if lots of events has been fired that should have been caught by the onStatus() method.
    This topic has been closed for replies.

    2 replies

    Participating Frequently
    March 6, 2008
    Yes, as Casey_ noted you must get the stream reference and set the handler directly. Stream objects are native objects, which means they are not created the same way as script objects, and they do not have prototypes.
    Participant
    March 19, 2008
    That code doesn't actually work, by the way. The stream starts to play, but since the stream did not originate with an actual client, FMS kills it off in a few minutes, thinking the client is idle.
    Participant
    March 6, 2008
    In order for you to recieve an event for any stream on the server you must be listening to that stream.

    Try this on your server along with your prototype and you should get the stream events:
    application.onAppStart = function()
    {
    trace("onAppStart");
    application.testStream = Stream.get("WhoCaresWhatIAmNamedAsLongAsIDoNotConflictWithARealStreamName");
    application.testStream.onStatus = function(info)
    {
    var level = info.level;
    var code = info.code;
    var description = info.description;
    var details = info.details;
    trace("onStatus(level='"+ level +"', code='"+ code +"', description='"+ description +"', details='"+ details +")");
    if (code == "NetStream.Play.UnpublishNotify")
    {
    trace("Do Your Magic")
    }
    };
    application.testStream.play("TestStream");
    }