Skip to main content
Inspiring
February 10, 2012
Answered

FMS multipoint publish, howto unPublish the streams?

  • February 10, 2012
  • 2 replies
  • 2450 views

Hi there and thanks for looking, I thinks it's something simple and I seem to not get it

I have FMLE source streaming to FMS #1, and FMS #1 is multipoint publishing to FMS #2. It works great, but when I stop FMLE source, the multipoint publishing from FMS #1 to FMS #2 doesn't stop (unpublish), and continues to stream empty (blank black) stream between the FMS servers.

So how do I ubpublish the multipoint publishing streams on the FMS #1 ? Thanks.

Here is my code in application live on FMS #1:


// called when the client publishes
application.onPublish = function(client, myStream) {
      trace(myStream.name + " is publishing into application " + application.name);
      if (myStream.name == "aaaaaaa"){
           trace("Republishing the stream into anotherInstance");
           nc = new NetConnection();
           nc.connect( "rtmp://xxxxxxxx" );
           ns = new NetStream(nc);
           // called when the server NetStream object has a status
           ns.onStatus = function(info) {
                trace("Stream Status: " + info.code)
                if (info.code == "NetStream.Publish.Start") {
                trace("The stream is now publishing");
           }
           }
           ns.setBufferTime(2);
           ns.attach(myStream);
           ns.publish( "sdfsdf11", "live" ); //sdfsdf11
      }
}
application.onUnpublish = function(client, stream) {
      trace("OnUnpublish triggered for: "+stream.name);

          // i think here needs to be more of some code ???
}

This topic has been closed for replies.
Correct answer chotgor1

ok after 2 years, I guess I will answer my own question, I just found out how to unpublish multi-point streaming, when the original encoder stops streaming..

application.onUnpublish = function(client, stream) {
      trace("OnUnpublish triggered for: "+stream.name);


          // the solution i tried today and worked:

    

     ns.publish(false);

          ns.attach(false);

          nc.close();

      
}

2 replies

chotgor1AuthorCorrect answer
Inspiring
July 10, 2013

ok after 2 years, I guess I will answer my own question, I just found out how to unpublish multi-point streaming, when the original encoder stops streaming..

application.onUnpublish = function(client, stream) {
      trace("OnUnpublish triggered for: "+stream.name);


          // the solution i tried today and worked:

    

     ns.publish(false);

          ns.attach(false);

          nc.close();

      
}

Adobe Employee
February 11, 2012

You guessed it right - the code needs to go there where you have pointed out - it should look like this

application.onUnpublish = function(client,stream){

     ns.publish(false);

      ns.attach(false);

}

But for above code to work you will have to declare your NetStream variable "ns" outside the scope of application.onPublish - so either make it global or scope it to application i.e. your entire code would look like below

application.onPublish = function(client, myStream) {
      trace(myStream.name + " is publishing into application " + application.name);
      if (myStream.name == "aaaaaaa"){
           trace("Republishing the stream into anotherInstance");
           application.nc = new NetConnection();
           application.nc.connect( "rtmp://xxxxxxxx" );
           application.ns = new NetStream(application.nc);
           // called when the server NetStream object has a status
           application.ns.onStatus = function(info) {
                trace("Stream Status: " + info.code)
                if (info.code == "NetStream.Publish.Start") {
                trace("The stream is now publishing");
           }
           }
           application.ns.setBufferTime(2);
           application.ns.attach(myStream);
           application.ns.publish( "sdfsdf11", "live" ); //sdfsdf11
      }
}
application.onUnpublish = function(client, stream) {
      trace("OnUnpublish triggered for: "+stream.name);

          // i think here needs to be more of some code ???

           application.ns.publish(false);

          application.ns.attach(false);
}

chotgor1Author
Inspiring
February 11, 2012

Thanks for prompt reply, but it is not unpublishing and throwing some error on the log:

...

Republishing the stream into anotherInstance

The stream is now publishing

OnPublish triggered for: aaaaaaaa

Sending error message: C:\...\application\live\main.asc: line 370:

TypeError: application.ns has no properties

Adobe Employee
February 13, 2012

Can you paste your whole code or send it across to me. I am trying to figure out why are you getting this error.

Also it would be good to wait for NetConnection to succeed before you use it to create NetStream.