Search code examples
actionscript-3flashnetstream

Pausing a NetStream while publishing


I have this hack-y solution for pausing and unpausing the NetStream that I'm publishing.

Upon playback, it does a nice jump-cut, but then after that it freezes in place for the amount of time that you stayed paused.

If you were to record 5 seconds, pause for 10 seconds, and then resume and continue recording for 5 more seconds, the total video would be 20 seconds, with 10 seconds of that being frozen on the first frame where you resume.

Can I have this not happen?

private function doPause():void
        {
            if(status=="recording"){
                myns.pause();
                myTimer.stop();
                status="paused";
                stage.addChild(pauseIcon);
                myns.attachCamera(null);
                myns.attachAudio(null);
            }
        }

        private function doResume():void
        {
            if(status=="paused"){
                myns.resume();
                myTimer.start();
                status="recording";
                stage.removeChild(pauseIcon);
                myns.attachCamera(myCam);
                myns.attachAudio(myMic);
            }
        }

Solution

  • I fixed it

    private function doPause():void
            {
                if(status=="recording"){
                    myns.pause();
                    myTimer.stop();
                    status="paused";
                    stage.addChild(pauseIcon);
                    myns.publish("false");
    
                }
            }
    
            private function doResume():void
            {
                if(status=="paused"){
                    myns.resume();
                    myTimer.start();
                    status="recording";
                    stage.removeChild(pauseIcon);
                    myns.publish(myTempFile,"appendWithGap");
                }
            }