Expand my Community achievements bar.

question - WebCamera Pod becomes null for when changing rooms

Avatar

Level 2

hello,

I'm having an issue with the webcamera pod, and hope I can get some help.  I can enter my main room with a default WebCamera pod just fine,  however I have a button in my flex app that logs the user out of the current room, creates a new room called here "newroom", and then re-subscribes the WebCamera pod.  Below is the code.

My problem is that if the user enables his/her camera in the main default room of my app, and then clicks the button to enter "newroom", when he/she enters the new room, the WebCamera pod is null.  I know this because I got a null error when I tried calling a .close() method on the WebCamera pod for the new room, and I'm not sure why it's null because my code calls a .subscribe() upon entering the new room.  Additionally, despite being null, I can see a snapshot of a webcam publisher from the main room that was carried over to the new room, except it is a still image that never refreshes or goes away.

Could it be because I have to also re-initialize the WebCamera pod?  I figure i don't have to since its part of the mxml, --that and I can use the code below for a WhiteBoard and SimpleChat in the newroom and it appears to work just fine (they don't become null when entering the new room).

Is there something I'm missing that is making the WebCamera Pod null?  I've been struggling with this for a while now, any help would be much appreciated!  Thank you.

private function clickHandler(event:MouseEvent):void

{

     webCameraGroup.close();

     afcsSession.logout();

     room = "newroom";

     afcsSession.roomURL="https://connectnow.acrobat.com/account/"+room;

     afcsSession.authenticator = auth;

     afcsSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE,here);

     afcsSession.login();

}

private function here(e:Event):void{

     webCameraGroup.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, sync);

     webCameraGroup.subscribe();

}

private function sync(e:Event):void{

     if (webCameraGroup.isSynchronized){

          Alert.show("cams synced");

       }

}

``````````````````````````````````

<mx:Button id="myWorldWideButton" click="clickHandler(event)" />

<rtc:WebCamera id="webCameraGroup" sharedID="default_WebCamera" height="100%" width="100%"  >

</rtc:WebCamera>

5 Replies

Avatar

Former Community Member

Hi ,

I tried to look through your code. I will past the code fixes here. Since you may be using the swc, and it may take few more days for the new version to be out, so I have subclassed a fix in WebCamera and I will attach the code here along with your example test code. I am not sure if this fix can go in our release down corner, but the code I am attaching should work for you.

I basically modified your code to switch between various rooms by using a different sharedID for webcam pod in different rooms. I think you should be using different sharedIDs for the collection Nodes while switching using the same session to different rooms on fly. That will keep things cleaner.

------------------------------------------------------

Test.mxml

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" x="0"  width="400" height="400"

    xmlns:rtc="AfcsNameSpace" creationComplete="init();" > <mx:Script>

            <![CDATA[

                  import mx.controls.Alert;

                  import com.adobe.rtc.events.CollectionNodeEvent;

                  import com.adobe.rtc.events.SessionEvent;

                 

                 

                  private var room:String ;

                 

                  private function clickHandler(event:MouseEvent):void

                  {

                   

                 

                        cSession.logout();

                        room = "myfourthroom";

                        cSession.roomURL="https://connectnow.acrobat.com/ myaccountname /" + room;

                       cSession.authenticator = auth;

                        cSession.login();

                        cSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE,here);

                 

                  }

                 

                    private function clickHandler2(event:MouseEvent):void

                  {

                   

                 

                        cSession.logout();

                        room = "mythirdroom";

                        cSession.roomURL="https://connectnow.acrobat.com/myaccountname/" + room;

                       cSession.authenticator = auth;

                        cSession.login();

                        cSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE,here);

                 

                  }

                 

                  private function here(e:Event):void{

                       webCameraGroup.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, sync);

                      

                        webCameraGroup.subscribe();

                  }

                 

                  private function sync(e:Event):void{

                  }

                 

                 

            ]]>

      </mx:Script>

     

      <authen:AdobeHSAuthenticator id="auth"  userName="XXXXXXX" password="XXXXXX" />

      <sess:ConnectSessionContainer id="cSession" authenticator="{auth}" width="100%" height="100%" 

            roomURL="https://connectnow.acrobat.com/myaccountname/mythirdroom";>

            <mx:HBox top="10" right="10" left="10" bottom="10" verticalGap="6" horizontalAlign="center">

                  <mx:VBox width="100%" height="100%" >

                        <mx:Button id="myWorldWideButton" label="switch to Room4 click="clickHandler(event)" />

                        <mx:Button id="myWorldWideButton1" label="Switch back to Room3" click="clickHandler2(event)" />

                       <subclass:WebCameraSubclass id="webCameraGroup" sharedID="default_WebCamera" height="100%" width="100%"  /> 

                  </mx:VBox>

            </mx:HBox>

      </sess:ConnectSessionContainer>

</mx:Application>

---------------------------------------------------

WebcamSubclass.mxml (overriding a function, for source you can refer to player 9's WebCamera.as , the 10 source code will be available shortly)

<?xml version="1.0" encoding="utf-8"?>

<WebCamera xmlns="com.adobe.rtc.pods.*" xmlns:mx="http://www.adobe.com/2006/mxml">

      <mx:Script>

            <![CDATA[

                  import com.adobe.rtc.events.StreamEvent;

                  import com.adobe.rtc.pods.cameraClasses.CameraModel;

                  import com.adobe.rtc.events.CameraModelEvent;

                  import com.adobe.rtc.events.CollectionNodeEvent;

                 

                  import com.adobe.rtc.core.session_internal ;

                 

                 

                  override protected function onSynchronizationChange(event:CollectionNodeEvent=null):void

                  {

                        if (_cameraModel && _cameraModel.isSynchronized) {

                              recreateSubscribers();

                              invalidateDisplayList();

                              addStartStopBtn();

                        }

                       

                        if (_startStopBtn) {

                              if ( _connectSession.sessionInternals.session_internal::connection as NetConnection == null ) {

                                    _startStopBtn.enabled = false ;

                              } else {

                                    _startStopBtn.enabled = _cameraModel.isSynchronized;

                              }

                        }

                       

                       

                        if ( event != null ) {

                              dispatchEvent(event);

                }

               

                if ( _cameraModel && !_cameraModel.isSynchronized ) {

                  if ( _startStopBtn ) {

                        _startStopBtn = null ;

                        _startStopState = STATE_START ;

                  }

                }

                  }

            ]]>

      </mx:Script>

</WebCamera>

---------------------------------------------------------------------------

Lastly, as a best practice, I normally prefer to use WebcamPublisher/Subscriber instead of the pods directly. It gives me more power to manipulate stuff and work at lower levels.

Hope these two codes help. Put the WebCameraSubclass.mxml in the some location as your Test.mxml. Please let me know if your problem gets solved or not.

Thanks

Hironmay Basu

Avatar

Former Community Member

Hi,

Following up on previous email, The webCamera pod isn’t null as you mentioned , but subscribing had some issues since you were using same session container and sharedIDs and switching between rooms at runtime.

Thanks

Hironmay Basu

Avatar

Level 2

Thanks so much for your help with this... I really appreciate you writing that class for me.  I've been trying really hard to get it working though, and created a new project from scratch but was still unable to get it going.  It does now switch rooms with less visible errors (i can see the 'start my cam' button in each room now) --but if i start a cam in one room and switch to the other, i still get a lingering screenshot of a publisher from the previous room (as well as myself --2 cams total)... is there something i'm still missing?

when i am in the new room, even though i see 2 cams, i can click on the 'start my cam' button but then the debugger gives me this error: 

Error: The stream cannot be published because it does not exist.

at com.adobe.rtc.sharedManagers::StreamManager/publishStream()[C:\work\main\connect\cocomo\src\com\adobe\rtc\sharedManagers\StreamManager.as:694]

at com.adobe.rtc.collaboration::WebcamPublisher/createMyStream()[C:\work\main\connect\cocomo\src\com\adobe\rtc\collaboration\WebcamPublisher.as:1091]

at com.adobe.rtc.collaboration::WebcamPublisher/publish()[C:\work\main\connect\cocomo\src\com\adobe\rtc\collaboration\WebcamPublisher.as:717]

at com.adobe.rtc.pods::WebCamera/startWebcam()[C:\work\main\connect\cocomo\src\com\adobe\rtc\pods\WebCamera.as:518]

at com.adobe.rtc.pods::WebCamera/onStartStopClick()[C:\work\main\connect\cocomo\src\com\adobe\rtc\pods\WebCamera.as:528]

I'm definitely using the subclass, but not sure what there is left to do.  any last thoughts? i can survive without the switch of rooms until the next release if need be.. thanks so much again for your help with this!

Avatar

Former Community Member

Hi ,

I think that was another fix I made in an earlier post where I attached the subclasses for webcampublisher /webcamsubscriber but you don't need to bother since the new release is there ! Launch your SDK Navigator application and it will ask you to update. Then unzip the latest SDK and get the SWCs from there. You can even get 10 source.

The updated swc should fix your problem. Let me know if you still face any issue. You can also do away with the previous subclass I sent to you earlier and that fix has been included.

Thanks

Hironmay Basu

Avatar

Level 2

Awesome!  thanks Hironmay!!