Expand my Community achievements bar.

Newbie question about record/playback

Avatar

Level 1

I'm a newbie to this forum. So. I hope this is not a stupid question.

I have an application which I want to have record, then, playback capabilities within the same application.

I have seen examples of Playback, and examples of recording. But. Noth both together.

I wrote a simple Flex client which has two sessions. One for recording, one for playback.

When I run the application. I can create the recording with no problems.

However. I can't then playback the recording in the same application instance.

I receieve a connection rejected exception.

If I restart the application. I can playback the recording with no problems.

Here is the source to my simple client.

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

<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

               xmlns:s="library://ns.adobe.com/flex/spark"

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

               xmlns:myutils="utils.*"

               horizontalAlign="center"

               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="initUsing(event)">

    <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

       

       

    </fx:Declarations>

   

   

    <fx:Script>

       

        <![CDATA[

           

           

            import com.adobe.rtc.authentication.AdobeHSAuthenticator;

            import com.adobe.rtc.authentication.PlaybackAuthenticator;

            import com.adobe.rtc.collaboration.AudioPublisher;

            import com.adobe.rtc.collaboration.AudioSubscriber;

            import com.adobe.rtc.events.StreamEvent;

            import com.adobe.rtc.session.ConnectSession;

            import com.adobe.rtc.session.ConnectSessionContainer;

           

            import mx.containers.HBox;

            import mx.containers.VBox;

            import mx.controls.Button;

            import mx.controls.ProgressBar;

            import mx.events.FlexEvent;

           

            import spark.components.VGroup;

           

            import utils.PlaybackBar;

           

       

           

            private function initUsing(event:Event):void {

               

           

               

            }

           

            protected function audioSub_creationCompleteHandler(event:FlexEvent):void {

                // TODO Auto-generated method stub

                audioSub.subscribe();   

            }

       

           

           

            private function stopRecordingHandler(event:Event):void {

               

                rSession.archiveManager.isRecording = false;

                audioPub.stop();

            }

           

            /****

             * When published stream is received, start polling the activity level of my microphone.

             */

            private function onAudioStreamReceive(p_evt:StreamEvent):void{

                trace("Audio stream received");

                audioActivityTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);

                audioActivityTimer.start();

               

               

            }

            /****

             * When the stream is deleted, stop polling the

             * activity level of microphone and mark the activity progress bar to 0.

             */

            private function onAudioStreamDelete(p_evt:StreamEvent):void

            {

               

                    if (audioPub.microphone != null ) {

                        audioActivityTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);

                        audioActivityTimer.stop();

                    }

                    audioActivityProgressBar.setProgress(0,100);

               

            }

           

            private function onTimerComplete(p_evt:TimerEvent):void {

               

                audioActivityTimer.start();

                if ( audioPub.isPublishing && !audioPub.isPaused ) {

                    audioActivityProgressBar.setProgress(audioPub.microphone.activityLevel,100);

                }

               

            }

           

            protected function recordLoginBtn_clickHandler(event:MouseEvent):void {

                // TODO Auto-generated method stub

                trace("inside recordLoginBtn_clickHandler");

                rSession.login();

            }

           

            protected function startPlaybackBtn_clickHandler(event:MouseEvent):void {

               

           

                currentState = "playbackMode";

                rSession.logout();

                rSession.close();

                pbSession.login();

            }

           

           

           

            protected function audioPub_creationCompleteHandler(event:FlexEvent):void {

               

               

                audioPub.addEventListener(StreamEvent.STREAM_RECEIVE,onAudioStreamReceive);

                audioPub.addEventListener(StreamEvent.STREAM_DELETE,onAudioStreamDelete);

           

            }

               

           

           

            protected function playbackLoginBtn_clickHandler(event:MouseEvent):void {

                currentState = "playbackMode";

               

                pbSession.login();

               

            }

           

            protected function startRecordingButton_clickHandler(event:MouseEvent):void {

               

                stopRecordingBtn.enabled = true;

                rSession.archiveManager.archiveID = TEST_RECORDING_1;

                rSession.roomURL = ROOM_URL;

                rSession.archiveManager.guestsAllowed = true;

                rSession.archiveManager.isRecording = true;

                audioPub.microphoneManager.micIndex = 3;

               

                audioPub.publish();

               

            }

           

            protected function stopRecordingButton_clickHandler(event:MouseEvent):void

            {

                rSession.archiveManager.isRecording = false;

                audioPub.stop();

                startPlaybackBtn.enabled = true;

                rSession.close();

                audioPub.close();

               

            }

           

           

       

           

            private var audioActivityTimer:Timer = new Timer(30,1);

            private const ROOM_URL:String = "https://collaboration.adobelivecycle.com/MYROOMURL/myfirstroom";

            private const TEST_RECORDING_1:String = "mytestrecording1";

           

           

        ]]>

    </fx:Script>

    <mx:states>       

      <mx:State name="recordMode"/>

      <mx:State name="playbackMode"/>

    </mx:states>

   

    <mx:VBox>

        <rtc:ConnectSessionContainer id="rSession" includeIn="recordMode" roomURL="{ROOM_URL}">

           

            <rtc:initialRoomSettings>

                <rtc:RoomSettings id="roomSettings" autoPromote="true" guestsMustKnock="false"/>

            </rtc:initialRoomSettings>

           

            <rtc:authenticator>

               

                <rtc:AdobeHSAuthenticator id="recAuth" userName="myusername" password="mypassword"/>

            </rtc:authenticator>

            <mx:VBox>

                <mx:HBox>

                    <mx:Button id="startRecordingBtn" label="Start Recording" click="startRecordingButton_clickHandler(event)"/>

                    <mx:Button id="stopRecordingBtn" label="Stop Recording" enabled="false" click="stopRecordingButton_clickHandler(event)"/>

                    <mx:Button id="startPlaybackBtn" label="Start Playback" enabled="false" click="startPlaybackBtn_clickHandler(event)"/>

                    <mx:Button id="playbackLoginBtn" label="Playback Login" enabled="true" click="playbackLoginBtn_clickHandler(event)"/>

                </mx:HBox>

               

                <mx:ProgressBar id="audioActivityProgressBar" x="325" y="300" width="325" height="37"

                                label="Volume" labelPlacement="center" mode="manual" paddingRight="30" color="#ff0000"/>

               

                <rtc:AudioPublisher id="audioPub" height="0" creationComplete="audioPub_creationCompleteHandler(event)"/>

               

            </mx:VBox>

           

        </rtc:ConnectSessionContainer>

       

        <rtc:ConnectSessionContainer id="pbSession" includeIn="playbackMode" autoLogin="false" archiveID="mytestrecording1" roomURL="{ROOM_URL}">

            <rtc:authenticator>

                <rtc:PlaybackAuthenticator

                    id="pbAuth"/>

            </rtc:authenticator>

           

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

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

                    <rtc:AudioSubscriber id="audioSub" height="0" creationComplete="audioSub_creationCompleteHandler(event)"/>

                    <myutils:PlaybackBar width="100%" height="200" />

                </mx:VBox>

            </mx:HBox>

        </rtc:ConnectSessionContainer> 

       

       

       

       

       

   

    </mx:VBox>

   

   

   

   

</mx:Application>

0 Replies