0 Replies Latest reply: Oct 7, 2014 11:10 AM by Mister_Mitbewohner RSS

    NetConnection and NetStream in Director: Is it impossible to have more than one incoming Stream?

    Mister_Mitbewohner Community Member

      Hi there,

       

      I'm working on a Director 11.5 video chat for 3 people. You shall see your webcam video as a little and the two you are connected with as a big video panel. So good so far, I managed to show my own webcam video without streaming it and managed to see one of the others as an incoming stream.


      The problem is: as soon as there's a second script initiating a second InStream (no matter how I name it), only the one with the lower sprite number shows it's stream. When I disable the script for this lower sprite, then the second one is playing, so it can't be due to an incorrect script.


      I already emilinated two misstakes which made it not working at all at the beginning:


      First I tried to use the NetConnection object (for sending my own video stream, works fine) also for creating an input stream. That didn't work. It's a different scene where I set up and play the inStreams (I made the NetConnection object global). So now I set up a new NetConnection for each stream: one outStream and two inStreams.

      First I also used only one swf member and made several sprites of it. This didn'Ät work at all, also using the same behavior for the two other-perople-players. So i copied ad pasted the swf and also the behavior. I also renamed every variable in the second behavior with a "2" at the end, just to be sure.

      Then it worked at least - but still only for one inStream.


      The architecure of my Director film is the following:


      I've got two scenes. First scene is an input field to type your name and a "connect" button. Behind this button there's a behavior setting a connection to the server (by using a swf sprite which isn't visible yet) and sending my webcam video and name to the server. This part works fine.


      director chat screenshot.png(Picture shows scene 2)


      Second scene consists of three swf sprites - one is to show my own webcam video directly from PC. This one already existed in the first scene, for I have to use a swf for setting up a NetConnection. The second and third swf sprites are connected to a behavior script which sets up a new connection (in exitFrame, with a bool variable "firsttime" to make sure it only happens once).

      I also have two drop down field each below a partner chat swf. Here I show all people who are logged in at the server, it automatically updates. The one you chose in the drop down is the video you will see in the swf sprite above. Thid works fine (if it works with the inStream).

      The script for playing the own webcam video is placed at the first frame of the second scene and only refers to the swf for my own video (which already occurs in scene 1). Well, that's all I think. I'll post the code for the two partner player swf here. Please have a look at it to find a misstake - or maybe again it's some strange Director behavior (like two sprites of one member didn't work) which I cannot think of...


      Code for the behavior script of the partner swf for partner 1. The script for partner 2 is exactly the same, but every variable has a "2" at it's end.


      global firsttime1
      global gUserList
      
      property gNetConn
      property InStream
      
      on exitFrame  me 
        if (firsttime1) then   
          pSprite = sprite(me.spritenum)   
          gNetConn = pSprite.newObject("NetConnection")   
          gNetConn.connect("rtmp://212.122.56.2/flashcam")   
          InStream = pSprite.newObject("NetStream", gNetConn)    put "InStream " & InStream
          InStream.play(gUserList[1])   
          pVideoClip = pSprite.getVariable("VideoClip",FALSE)
          put "pVideoClip " & pVideoClip
          pVideoClip.attachVideo(InStream)   
          firsttime1 = false
        end if 
      end exitFrame
      
      on updateInStream aArg1, aArg2
      -- that method is called by the drpdown script when some change occured 
        put "neuer Partner 1: " & aArg2
        partner = aArg2
        InStream.play(partner)  
      end updateInStream
      
      on endsprite me 
        if not(voidP(InStream)) then
          InStream.close()
        end if   
      end endsprite
      
      


      I'd appreciate every idea or help! Thank you!


      Jana