iOS Front Camera?

Avatar

Avatar

daminee80

Avatar

daminee80

daminee80

10-06-2011

I am trying to get the fron camera to work, but I am not sure exactly how I am supposed to use the "getCamera" method...I used a slightly modified version of Raff's code that he posted, some of the project specific code was removed... Also, I am creating a tabbed program, however whenever I switch tabs it attemps to relogin and the streem is interrupted.

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

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

             xmlns:collaboration="com.adobe.rtc.collaboration.*"

             xmlns:authentication="com.adobe.rtc.authentication.*"

             xmlns:rtc="http://ns.adobe.com/rtc"

             xmlns:s="library://ns.adobe.com/flex/spark" title="test2" viewActivate="init()">

       <fx:Declarations>               

             <collaboration:WebcamPublisher  id="webcamPub" connectSession="{sess}"/>

             <collaboration:WebcamSubscriber id="webcamSub" connectSession="{sess}" webcamPublisher="{webcamPub}"/>        

             <collaboration:AudioPublisher   id="audioPub" connectSession="{sess}"/>

             <collaboration:AudioSubscriber  id="audioSub"  connectSession="{sess}"/>

       </fx:Declarations>

       <fx:Script>

             <![CDATA[

                    import com.adobe.rtc.authentication.AdobeHSAuthenticator;

                    import com.adobe.rtc.clientManagers.MicrophoneManager;

                    import com.adobe.rtc.events.AuthenticationEvent;

                    import com.adobe.rtc.events.CollectionNodeEvent;

                    import com.adobe.rtc.events.ConnectSessionEvent;

                    import com.adobe.rtc.events.SessionEvent;

                    import com.adobe.rtc.events.SharedPropertyEvent;

                    import com.adobe.rtc.events.StreamEvent;

                    import com.adobe.rtc.messaging.UserRoles;

                    import com.adobe.rtc.session.ConnectSession;               

                    import com.adobe.rtc.sharedManagers.descriptors.StreamDescriptor;

                    import com.adobe.rtc.sharedManagers.descriptors.UserDescriptor;

                    import com.adobe.rtc.sharedModel.SharedProperty;

                   

                    import mx.core.IFlexDisplayObject;

                   

                   

                    [Bindable]

                    protected var sess:ConnectSession;

                   

                    [Bindable]

                    private var auth:AdobeHSAuthenticator; 

                   

                    private function init():void

                    {                               

                           if(sess==null){

                                 auth = new AdobeHSAuthenticator();

                                 sess = new ConnectSession();

                                

                                 sess.authenticator = auth;

                                

                                 auth.userName="";

                                 auth.password="";

                                 auth.protocol = "rtmfp";

                                 sess.roomURL="https://connectnow.acrobat.com/foobar/footest";

                                 sess.authenticator=auth;

                                

                                 sess.addEventListener(SessionEvent.ERROR, onEventNotification);

                                 sess.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE, onEventNotification);

                                 auth.addEventListener(AuthenticationEvent.AUTHENTICATION_FAILURE, onEventNotification);

                                 auth.addEventListener(AuthenticationEvent.AUTHENTICATION_SUCCESS, onEventNotification);      

                                

                                

                                 Camera.getCamera("1");

                           }                               

                          

                           if(!sess.isSynchronized) {                                 

                                 sess.login();                          

                           }

                    }

                   

                    /**

                    * Process  Events

                    */

                    private function onEventNotification(p_event:Event):void

                    {

                           if (p_event.type == SessionEvent.SYNCHRONIZATION_CHANGE) {

                                 if (sess.isSynchronized) {                                                                                                                                                  

                                       

                                        webcamSub.subscribe();

                                        webcamPub.publish();

                                        audioSub.subscribe();

                                        audioPub.publish();

                                        camera.addChild(webcamSub);

                                        webcamSub.width = camera.width;

                                        webcamSub.height = camera.height;

                                       

                                        if ( sess.userManager.myUserRole == UserRoles.OWNER ) {

                                              sess.roomManager.autoPromote = true ;

                                        }

                                       

                                 }

                           }

                    }

                   

             ]]>

       </fx:Script>

      

       <s:Group width="100%" height="100%" id="group">

             <s:SpriteVisualElement id="camera" x="0" y="0" width="100%" height="50%"/>

            

       </s:Group>

</s:View>

View Entire Topic

Avatar

Avatar

Raff_

Employee

Avatar

Raff_

Employee

Raff_
Employee

03-01-2012

You should bring this up with on the FlashPlayer / AIR forums. This is how they implemented support for front facing camera (don't ask me why) and I don't know if there are plan to change that.

Of course you can rotate the camera component, but you'll need to do that both on the transmitting side (webcam publisher) and the receiving side (webcam subscriber) and possibly have a shared property that tells all clients what orientation to use.