Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

WebCam sharing in Connect Room

Avatar

Level 2

Hi,

I have downloaded the latest LCCS with a set of sample app.

I am intested in the WebCamera, I use Flex Builder 4 with 4.1 SDK on this sample with my room created.

After I launch the app, I start the camera, I can see subscriber shows up on the App, then I use another browser to the connect room, after I log into the connect room, I can see the WebCam window popup, showing a blank screen.

Originally I thought something wrong with the app, but I can see the Publisher if I launch the App in 2 browsers, somehow, the connect room cannot see the publisher, do you know why?

Thanks

8 Replies

Avatar

Employee

Hi,

Can you try this code and check if you are hitting an error. Also try a simple app just with the WebCamera pod.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:rtc="http://ns.adobe.com/rtc">
     
     <mx:Script>
          <![CDATA[
               import com.adobe.coreUI.controls.CameraUserBar;
               import com.adobe.rtc.collaboration.WebcamSubscriber;
               import com.adobe.rtc.events.CollectionNodeEvent;
               import com.adobe.rtc.events.SessionEvent;
               import com.adobe.rtc.events.SharedPropertyEvent;
               import com.adobe.rtc.events.StreamEvent;
               import com.adobe.rtc.events.UserEvent;
               import com.adobe.rtc.messaging.UserRoles;
               import com.adobe.rtc.sharedManagers.StreamManager;
               import com.adobe.rtc.sharedManagers.descriptors.StreamDescriptor;
               import com.adobe.rtc.sharedModel.SharedProperty;
               
               protected var _camSubscribers:Object;
               protected var _currentSubscriber:WebcamSubscriber ;
               protected var _sharedProperty:SharedProperty ;
               
               /**
                *  Handler for the stop and start buttons.
                */
               protected function startBtn_clickHandler(event:MouseEvent):void
               {
                    if ( startBtn.label == "Start" ) {
                         webCamPub.publish();
                         startBtn.label = "Stop" ;
                         
                         if (_camSubscribers && _camSubscribers[cSession.userManager.myUserID]) {
                              var webcamSubscriber:WebcamSubscriber = _camSubscribers[cSession.userManager.myUserID];
                              smallSubscriberContainer.addChild(webcamSubscriber);
                         }
                    }else if (startBtn.label == "Stop" ){
                         webCamPub.stop();
                         startBtn.label = "Start" ;
                    }
               }
               
               /**
                * SynchronizationChange event handler. Initialize the Shared property used to sync the Subscriber info
                * who would be the centre of the app.
                */
               protected function cSession_synchronizationChangeHandler(event:Event):void
               {
                    if (cSession.isSynchronized) {
                         _sharedProperty = new SharedProperty();
                         _sharedProperty.isSessionDependent = true ;
                         _sharedProperty.sharedID = "webcamShare2" ;
                         _sharedProperty.connectSession = cSession ;
                         _sharedProperty.subscribe();
                         _sharedProperty.addEventListener(SharedPropertyEvent.CHANGE,onChange);
                         
                         _camSubscribers = new Object();
                         cSession.streamManager.addEventListener(StreamEvent.STREAM_RECEIVE,onStreamRecieved);
                         cSession.streamManager.addEventListener(StreamEvent.STREAM_DELETE,onStreamDelete);
                         addExistingStreamers();
                    }
               }
               
               /**
                *  Set up a thumbnail subscriber for every new camera stream
                */
               protected function onStreamRecieved(p_evt:StreamEvent):void
               {
                    if (p_evt.streamDescriptor.type == StreamManager.CAMERA_STREAM) {
                         setUpfromDescriptor(p_evt.streamDescriptor);
                    }
               }
               
               /**
                * Clicking a subscriber updates the shared value, which in turn enlarges the thumbnail after getting updated
                */
               protected function onClick(p_evt:MouseEvent):void
               {
                    if ( (p_evt.currentTarget is WebcamSubscriber) &&  !(p_evt.target.parent is CameraUserBar)) {
                         _sharedProperty.value = (p_evt.currentTarget as WebcamSubscriber).publisherIDs;
                    }
               }
               
               /**
                * Clean up when a user stops publishing his camera or exits his app.
                */
               protected function onStreamDelete(p_evt:StreamEvent):void
               {
                    if (p_evt.streamDescriptor.type == StreamManager.CAMERA_STREAM) {
                         if ( _camSubscribers[p_evt.streamDescriptor.streamPublisherID]) {
                              var webcamSubscriber:WebcamSubscriber = _camSubscribers[p_evt.streamDescriptor.streamPublisherID];
                              if (webcamSubscriber) {
                                   smallSubscriberContainer.removeChild(webcamSubscriber);     
                              }
                              if (p_evt.streamDescriptor.streamPublisherID != cSession.userManager.myUserID) {
                                   webcamSubscriber.removeEventListener(UserEvent.STREAM_CHANGE,onCameraPause);
                                   webcamSubscriber.removeEventListener(UserEvent.USER_BOOTED,onUserBooted);
                                   delete _camSubscribers[p_evt.streamDescriptor.streamPublisherID];
                                   webcamSubscriber.close();
                                   webcamSubscriber = null;
                              } else {
                                   if (_currentSubscriber && _currentSubscriber.publisherIDs[0] == cSession.userManager.myUserID) {
                                        _sharedProperty.value = null;
                                   }
                              }
                         }
                    }
               }
               
               /**
                * Logic for handling the Pause event on CameraUserBar on every Subscriber
                */
               protected function onCameraPause(p_evt:UserEvent):void
               {
                    var userStreams:Array = cSession.streamManager.getStreamsForPublisher(p_evt.userDescriptor.userID,StreamManager.CAMERA_STREAM);
                    
                    if (userStreams.length == 0) {
                         trace("onCameraPause: no userStreams");
                         return;
                    }
                    
                    for (var i:int = 0; i< userStreams.length ; i++ ) {
                         if (userStreams[i].type == StreamManager.CAMERA_STREAM ) {
                              break;
                         }
                    }
                    
                    var streamDescriptor:StreamDescriptor = userStreams[i];
                    if ( streamDescriptor.streamPublisherID == cSession.userManager.myUserID ) {
                         cSession.streamManager.pauseStream(StreamManager.CAMERA_STREAM,!streamDescriptor.pause,streamDescriptor.streamPublisherID);
                    }     
               }
               
               /**
                * Initial set up of all users who are streaming when this app launches
                */
               protected function addExistingStreamers():void
               {
                    var streamDescritpors:Object = cSession.streamManager.getStreamsOfType(StreamManager.CAMERA_STREAM);
                    for (var i:String in streamDescritpors) {
                         setUpfromDescriptor(streamDescritpors[i]);
                    }
               }
               
               /**
                * Helper method to create a thumbnail subscriber.
                */
               protected function setUpfromDescriptor(p_descriptor:StreamDescriptor):void
               {
                    if (! _camSubscribers[p_descriptor.streamPublisherID]) {
                         var webCamSubscriber:WebcamSubscriber = new WebcamSubscriber();
                         webCamSubscriber.connectSession = cSession ;
                         webCamSubscriber.addEventListener(UserEvent.STREAM_CHANGE,onCameraPause);
                         webCamSubscriber.addEventListener(UserEvent.USER_BOOTED,onUserBooted);
                         webCamSubscriber.webcamPublisher = webCamPub;
                         webCamSubscriber.subscribe();
                         webCamSubscriber.sharedID = p_descriptor.streamPublisherID;
                         webCamSubscriber.publisherIDs = [p_descriptor.streamPublisherID];
                         webCamSubscriber.height = webCamSubscriber.width = 180;
                         webCamSubscriber.addEventListener(MouseEvent.CLICK, onClick);
                         smallSubscriberContainer.addChild(webCamSubscriber);
                         _camSubscribers[p_descriptor.streamPublisherID] = webCamSubscriber;
                    }
               }
               
               /**
                * This method is the listener to SharedPropertyEvent.CHANGE event. It updates the centred subscribes as its value
                * changes.
                */
               protected function onChange(p_evt:SharedPropertyEvent):void
               {
                    if ( _currentSubscriber != null ) {
                         _currentSubscriber.removeEventListener(UserEvent.USER_BOOTED,onUserBooted);
                         _currentSubscriber.removeEventListener(UserEvent.STREAM_CHANGE,onCameraPause);
                         centeredSubscriber.removeChild(_currentSubscriber);
                         _currentSubscriber.close();
                         _currentSubscriber = null ;
                    }
                    
                    if ( _sharedProperty.value == null || _sharedProperty.value.length == 0 ) {
                         return ;
                    }
                    
                    
                    _currentSubscriber = new WebcamSubscriber();
                    _currentSubscriber.connectSession = cSession ;
                    _currentSubscriber.subscribe();
                    _currentSubscriber.webcamPublisher = webCamPub ;
                    _currentSubscriber.publisherIDs = _sharedProperty.value ;
                    _currentSubscriber.addEventListener(UserEvent.USER_BOOTED,onUserBooted);
                    _currentSubscriber.addEventListener(UserEvent.STREAM_CHANGE,onCameraPause);
                    _currentSubscriber.width = _currentSubscriber.height = 500;
                    centeredSubscriber.addChild(_currentSubscriber);
               }
               
               /**
                * Logic for handling the Close event on CameraUserBar on every Subscriber
                */
               protected function onUserBooted(p_evt:UserEvent=null):void
               {
                    var tmpFlag:Boolean = false;
                    if (_currentSubscriber && _currentSubscriber.publisherIDs[0] == p_evt.userDescriptor.userID) {
                         if (_currentSubscriber.parent) {
                              _currentSubscriber.removeEventListener(UserEvent.USER_BOOTED,onUserBooted);
                              _currentSubscriber.removeEventListener(UserEvent.STREAM_CHANGE,onCameraPause);
                              _currentSubscriber.close();
                              _currentSubscriber.parent.removeChild(_currentSubscriber);
                              _currentSubscriber = null;
                              _sharedProperty.value = null;
                         }
                         tmpFlag = true;
                    }
                    
                    if ( _camSubscribers[p_evt.userDescriptor.userID]) {
                         var webcamSubscriber:WebcamSubscriber = _camSubscribers[p_evt.userDescriptor.userID];
                         tmpFlag = true;
                    }
                    
                    if (tmpFlag) {
                         webCamPub.stop();
                         startBtn.label = "Start";
                    }
               }
               
               
          ]]>
     </mx:Script>
     
     <!--
     You would likely use external authentication here for a deployed application;
     you would certainly not hard code Adobe IDs here.
     -->
     <rtc:AdobeHSAuthenticator
          id="auth"
          userName="Your Username"
          password="Your password" />
     <rtc:ConnectSessionContainer id="cSession" authenticator="{auth}" width="100%" height="100%" roomURL="Your RoomUrl">
          <mx:VBox id="rootContainer" width="100%" height="800" horizontalAlign="center">
               <rtc:WebcamPublisher width="1" height="1" id="webCamPub"/>
               <mx:VBox width="500" height="500" id="centeredSubscriber" horizontalAlign="center" verticalAlign="middle"/>
               <mx:Label text="Click on a Subscriber thumbnail to make it bigger." />
               <mx:HBox width="100%" height="200" horizontalAlign="center" verticalAlign="top" id="smallSubscriberContainer" creationComplete="cSession_synchronizationChangeHandler(event)"/>
               <mx:Button  id="startBtn" label="Start"  click="startBtn_clickHandler(event)" height="20"/>
          </mx:VBox>
     </rtc:ConnectSessionContainer>
</mx:Application>

Thanks

Arun

Avatar

Level 2

Thanks for your reply.

I just tried it. It only works when I use player9/lccs.swc, anything else (ie: player10 / player10.1) doesn't work.

Thanks

Avatar

Employee

Can you try this app that I uploaded to test a different issue - blogs.adobe.com/arunpon/files/2011/05/WebCameraFinal31.swf

This app was built using 10.1 and the same code I posted, and it works at our end.

Thanks

Arun

Avatar

Level 2

Which connect room should I use?

I just launch the app, I can not see myself as subscriber after I click start.

Thanks

Avatar

Employee

The room details are embedded within the app.

Can you check your player settings. I just double checked, and the app works at our end. Not sure why it would work just for player 9 & fail for 10 & 10.1 for the same application code.

Thanks

Arun

Avatar

Level 2

I need to know the connect room. The problem is Connect room doesn't show the WebCam.

I start (publish) the webcam inside the App, the subscriber in the App working fine, then, I go into the connect room, the subscriber in the connect room shows black screen. If I compile the app with Player9 SWC, do the same thing, now I can see the web cam is subscribed inside the connect room. So I need the connect room in order to try it out.

I am using player 10.2 on both App and Connect Room.

Thanks

Avatar

Former Community Member

Hi Alan,

Could you explain the problem more clearly? What "connect room" are you

talking about?

nigel

Avatar

Level 2

OK.

I registered the developer account here

https://cocomo.acrobat.com/

Then I download the SWC from the LCCS Navigator, I also use the LCCS Navigator to create my testing room.

I am trying to publish my WebCam, so I launch my App, and start to publish my webcam. On the otherside, I go into my testing room

The room url could be something like: http://na2.collaboration.adobelivecycle.com/<username>/<room>;

Once I join the room through the Adobe Connect, I can see the webcam window popup, suppose it should act as subscriber and see the publisher (The App).

I can only see the publisher in the room if my App is compiled using player9 lccs.swc.

Very strange.

Thanks