Skip to main content
October 14, 2009
Answered

Looping to Live Stream - onPublish?

  • October 14, 2009
  • 1 reply
  • 651 views

Hello everyone,

I'm an extreme newbie, and I finally have my videos looping, but I want them to stop looping and cut to a live stream whenever we go live with our broadcast. Can someone go into detail as to the code I need to switch from the looping videos to the live stream? I'm pretty sure it's done with onPublish, but again, I'm a newbie so I need all the help I can get.

Here is my main.asc. Thanks in advance!

application.onAppStart = function(){
this.clientStream = Stream.get("clientPlayStream");

this.clientStream.play("myfile", 0, -1);

application.onStatus = function(info){
if(info.code=="NetStream.Play.Stop") {
//do some code in here to restart the stream
this.clientStream.play("myfile", 0, -1);
}
}
}

    This topic has been closed for replies.
    Correct answer

    Yes... you can use application.onPublish and application.onUnpublish to handle it.

    application.onPublish = function(client, stream){

    if(stream.name == "therightlivestream"){

    this.clientStream.play("therightlivestream", -1, -1);

    }

    application.onUnpublish = function(client, stream){

    if(stream.name == "therightlivestream"){

    this.clientStream.play("myfile", 0, -1);

    }

    1 reply

    Correct answer
    October 14, 2009

    Yes... you can use application.onPublish and application.onUnpublish to handle it.

    application.onPublish = function(client, stream){

    if(stream.name == "therightlivestream"){

    this.clientStream.play("therightlivestream", -1, -1);

    }

    application.onUnpublish = function(client, stream){

    if(stream.name == "therightlivestream"){

    this.clientStream.play("myfile", 0, -1);

    }

    October 15, 2009

    Worked perfectly! Thanks!!!!!