1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
public function startRecordFlv(camera:Camera, mic:Microphone, video:Video, timer:Timer, status:String):void
{
if (status == "ready" || status == "pause")
{
timer.start();
this._changeStatus("recording");
this.setStreamName();
var recording:String = status == "ready" ? "record" : "append" ;
this._video = video;
trace(">> [STREAMING] => "+ recording + " => " + streamName);
this._ns.attachCamera(camera);
this._ns.attachAudio(mic);
this._ns.publish(streamName, recording);
} else {
trace(" >> ERROR : cannot start recoding on status:" + status);
}
} // startRecordFlv()
public function startPlayBack(video:Video, status:String):void
{
if ( status == "stop" || status == "playback")
{
// Close the connection and the stream if it's a double playback ( press two times on the button )
if ( status == "playback" )
{
this._nsOut.close();
this._ncOut.close();
}
this._changeStatus("playback");
video.clear();
this._ncOut.connect(null);
this._nsOut = new NetStream(this._ncOut);
this._nsOut.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
this._nsOut.addEventListener(SecurityErrorEvent.SECURITY_ERROR, ErrorsHandler.onSecurityError);
this._nsOut.addEventListener(AsyncErrorEvent.ASYNC_ERROR, ErrorsHandler.onAsyncError);
var ob:Object = new Object();
ob.onMetaData = onMetaDataHandler;
this._nsOut.client = ob;
this._nsOut.bufferTime = 5;
this._nsOut.receiveVideo(true);
this._nsOut.receiveAudio(true);
video.attachNetStream(this._nsOut);
this._nsOut.seek(0);
this._nsOut.play("http://" + this._serverCgf.host + ":5080/" + this._serverCgf.appName + "/streams/" + streamName + ".flv", -1, -1);
} else {
trace(">> ERROR : cannot start playback on status:" + status);
}
} // startPlayBack()
public function pauseFlv(timer:Timer, status:String):void
{
if( status == "recording" )
{
this._ns.close();
timer.stop();
this._changeStatus("pause");
} else {
trace(">> ERROR : Cannot record on status : " + status);
}
} // stopPlayback() |
Partager