Skip navigation
Tomas_Mirezko
Currently Being Moderated

TypeError: Stream.destroy is not a function

May 10, 2011 7:23 AM

Hello Adobe geeks!

 

I am trying to destroy a NetStream published from client -- application.onUnpublish handler

 

but I get this error: TypeError: Stream.destroy is not a function

 

According to http://help.adobe.com/en_US/flashmediaserver/ssaslr/WS5b3ccc516d4fbf35 1e63e3d11a11afc95e-7e42.html#WSdcb604046d78cda0-add5b6512f9ccc2d4e-800 0

 

Example

The following example destroys a stream called streamA:

// Get a stream. 
streamA = Stream.get("clientStream1"); 
// Destroy the stream. 
Stream.destroy(streamA);

 

Call Stream.destroy() to unlink and clean up a stream resource.

 

application.onUnpublish = function (client /*Client*/, stream /*Stream*/) {
    trace("Application.onUnpublish > client " + client.userId + " stopped publishing " + stream.name);

    Stream.destroy();
}

 

How can I remove a stream created by user?

 

Thanks!

 

T.

 
Replies
  • Currently Being Moderated
    May 10, 2011 10:27 AM   in reply to Tomas_Mirezko

    Hi,

     

    Thanks for your interest.

     

    Stream.destroy() is a server side function that is available through scripting on the server. I guess you are trying to use it on the NetStream object on the client side which is not possible.

     

    You may need to make a server side stream object for your client's stream and as per the documentation resource you referred, you should be able to destoy the stream.

     

    Hope it helps. Thank you  !

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2011 8:38 PM   in reply to Tomas_Mirezko

    Thanks for the code snippet. Even though you are using the Stream.destroy on the server side, you are still trying to destroy a client side stream (which is passed to the onPublish event). I think the Stream.destroy would function only for streams that are made on the server side using Stream.get(). I am not 100 % sure of this but reading the docuementation reference you mentioned above on this thread seems that this is indeed the behavior.


    So there is difference between (only in the way they are handled) server side and client side streams. You can create and 'attach' a server side stream like this :

     

    s = Stream.get("serversidestreamj");

    s.play("your client side stream ob");

    s.anyfunction; (ex : s.record() etc).

     

    and now, this 's' can be destroyed using Stream.destroy but not the client side one.

     

    Let us know if this helps. Thank you !

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 1:36 PM   in reply to Tomas_Mirezko

    I have encountered this same problem. I am generating a new stream on the server side and want to destroy it, but the function is not recognized.

     

    The documentation appears to be wrong.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 10:17 PM   in reply to mmah-umd

    Hi,

     

    Can you paste the code snippet you're using? I tried a simple streamObj.destroy() at me end and it doesn't throw any such errors for me.

     

    Thanks,

    Apurva

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 27, 2012 11:59 AM   in reply to Apurva Udaykumar

    I have tried this both as a static function (as shown in the documentation):

        var s = Stream.get(streamName);

         Stream.destroy(s);

    "Stream.destroy is not a function"

     

    and as a property function for

         s.destroy();

    "s.destroy is not a function"

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points