Skip to main content
Participant
October 26, 2011
Question

getting stream in onpublish

  • October 26, 2011
  • 1 reply
  • 458 views

I have an application that streams live video between two stations to create a "conference".  I am working on recording these streams for later playback.  The two sides can connect at different times.  What I want to do is make it so that the recording only starts when both sides are connected and then it ends when either of them disconnect.  That way the videos at least start and stop at the same time.  I have been using the code below, but it's not working like I would expect.  This code is in the OnPublish event.  First I determine what the id of the other connecting stream is.  Then, I try to use that to start recording both streams at once.  My main problem so far is that I can't seem to retrieve the other stream.  The stream name that is being published matches iOtherStationNumber in the admin console, but the program never makes it into the " if (sOther)" part.  I always get the "sOther is nothing message".

var sOther = Stream.get(iOtherStationNumber);

if (sOther)
{
  trace("setting to record");
  sOther.play(iOtherStationNumber);
  sOther.record();

  myStream.record();
  trace("set to record");
}
else
{
  trace("sOther is nothing");
}

    This topic has been closed for replies.

    1 reply

    Adobe Employee
    October 27, 2011

    Try removing "var" and just have sOther and see if it works.

    Participant
    October 31, 2011

    Well, I found another way to do this that worked for me.  This is what I used in case it helps anyone else:

    for (i = 0; i < application.streams.length; i++)

      {

       if (bRecordingStarted == "true")

       {

        application.streams.record("append");

       }

       else

       {

        application.streams.record();

       }

      }

    I add the streams to the array in the onPublish event and remove them in the onUnPublish event.