Con FMS puedo asignar un tiempo determinado en el buffer para el envio del sonido?
mejor dicho esta linea.
out_ns.setBufferTime (480);
Adjunto de todas formas la clase que hice.
He visto en varias paginas que es posible seguir grabando apesar que se pierda la conexion.
y grabar despues de recuperar la conexion.
Ej: http://www.springdoo.com
Muchas gracias.
Código :
class com.SoundRecorder extends MovieClip {
/* ---- */
private var _record_stop_mc:MovieClip;
private var _play_pause_mc:MovieClip;
private var client_nc:NetConnection;
private var in_ns:NetStream;
private var out_ns:NetStream;
private var client_mic:Microphone;
private var conState:String;
private var nInterval:Number;
private var _mediaServer:String = "rtmp://server.com/app";
/* ---- */
public function SoundRecorder (Void) {
void initStreams ();
}
/* ---- */
private function initStreams (Void):Void {
client_mic = Microphone.get ();
client_nc = new NetConnection ();
client_nc.connect (_mediaServer);
client_nc["parent"] = this;
client_nc.onStatus = function (info:Object):Void {
trace ("Level: " + info.level + newline + "Code: " + info.code + newline);
if (info.code.toString ().indexOf ("Success") <> -1) {
this.parent.buttonActions ();
}
if (info.code == "NetConnection.Connect.Failed") {
trace ("Cannot connect to Flash Server");
}
if (info.code == "NetConnection.Connect.Rejected") {
trace ("Cannot connect to Flash Server");
}
};
out_ns = new NetStream (client_nc);
in_ns = new NetStream (client_nc);
out_ns.setBufferTime (480);
//8 Minutes
in_ns.setBufferTime (2);
nInterval = setInterval(checkBuffer, 100, out_ns);
}
/* ---- */
private function doRecord (Void):Void {
trace ("RECORDING");
out_ns.attachAudio (client_mic);
out_ns.setRate (44);
client_mic.setSilenceLevel (0);
out_ns.publish ("recorder2", "record");
}
/* ----- */
private function doStopRecord (Void):Void {
out_ns.close ();
//out_ns.publish ("recorder2", "append");
}
/* ------ */
private function doPlay (Void):Void {
in_ns.onStatus = function (info:Object) {
trace ("Level: " + info.level + newline + "Code: " + info.code);
};
in_ns.play ("recorder2");
}
/* ---- */
private function checkBuffer (my_ns:NetStream):Void {
trace(my_ns.bufferTime + " ++ " + my_ns.bufferLength);
if (my_ns.bufferLength > 0) {
trace ("Saving Message ");
}
}
}
/* ---- */
private function buttonActions (Void):Void {
_record_stop_mc.parent = this;
_record_stop_mc.onRelease = function ():Void {
if (this._currentframe == 1) {
this.gotoAndStop (2);
void this.parent.doRecord ();
} else {
this.gotoAndStop (1);
void this.parent.doStopRecord ();
}
};
_play_pause_mc.parent = this;
_play_pause_mc.onRelease = function ():Void {
if (this._currentframe == 1) {
void this.parent.doPlay ();
this.gotoAndStop (2);
} else {
this.gotoAndStop (1);
this.parent.in_ns.pause ();
}
};
}
}
