I had at least a week. I am trying to record a video file in AMS. It works fine almost all the time, with the exception of 1 out of 10 or 15 recording sessions, I never get "NetStream.Unpublish.Success" in my network stream from AMS when I close the stream. I connect to AMS using rtmpt, when this happens, it seems to work fine on rtmp. Also, it looks like this only happens on Mac safari, but since it's so choppy, I don't believe it. Here is my main thread:
// just a way to use promises with netStatusEvents private function netListener(code:String, netObject:*):Promise { var deferred:Deferred = new Deferred(); var netStatusHandler:Function = function (event:NetStatusEvent):void { if (event.info.level == 'error') { deferred.reject(event); } else if (event.info.code == code) { deferred.resolve(netObject); // we want this to be a one time listener since the connection can swap between record/playback netObject.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); } }; netObject.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); return deferred.promise; } // set up for recording private function initRecord():void { Settings.recordFile = Settings.uniquePrefix + (new Date()).getTime(); // detach any existing NetStream from the video _view.video.attachNetStream(null); // dispose of existing NetStream if (_videoStream) { _videoStream.dispose(); _videoStream = null; } // disconnect before connecting anew (_nc.connected ? netListener('NetConnection.Connect.Closed', _nc) : Promise.when(_nc)) .then(function (nc:NetConnection):void { netListener('NetConnection.Connect.Success', _nc) .then(function (nc:NetConnection):void { _view.video.attachCamera(_webcam); // get new NetStream _videoStream = getNetStream(_nc); ExternalInterface.call("CTplayer." + Settings.instanceName + ".onRecordReady", true); }, function(error:NetStatusEvent):void { ExternalInterface.call("CTplayer." + Settings.instanceName + ".onError", error.info); }); _nc.connect(Settings.recordServer); }); // end ncClose if (_nc.connected) _nc.close(); } // stop recording private function stop():void { netListener('NetStream.Unpublish.Success', _videoStream) .then(function (ns:NetStream):void { ExternalInterface.call("CTplayer." + Settings.instanceName + ".onRecordStop", Settings.recordFile); }); _videoStream.attachCamera(null); _videoStream.attachAudio(null); _videoStream.close(); } // start recording private function record():void { netListener('NetStream.Publish.Start', _videoStream) .then(function (ns:NetStream):void { ExternalInterface.call("CTplayer." + Settings.instanceName + ".onRecording"); }); _videoStream.attachCamera(_webcam); _videoStream.attachAudio(_microphone); _videoStream.publish(Settings.recordFile, "record"); // fires NetStream.Publish.Success }
Update Now I use a new attempt to NetConnection for each connection, and also do not force port 80 (see My "answer" below). This did not solve my connection problems, only made cases more infrequent. Now, like every week or so, I still have a random ams or flash crash. Most recently, someone made a recording, and then the flash player was not able to download the video for playback. Ams logs show an attempt to connect, and then nothing. At the very least, there should be a replay event registered to load metadata. It is quite difficult and impossible to debug.
source share