# HG changeset patch
# User cavaliet
# Date 1338565617 -7200
# Node ID 9c9db6355381d9bc68b66167b6b33f161fe304ce
# Parent 4928ecd06b44e7a950c3f34c8df639c6f58b459e
first step of mic recorder
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic.as
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic.as Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,1 @@
+package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.display.Sprite;
import flash.system.Security;
import flash.events.MouseEvent;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.events.AsyncErrorEvent;
import flash.events.ErrorEvent;
import flash.media.Microphone;
import flash.net.NetStream;
import flash.utils.getTimer;
public class record_mic extends MovieClip {
private var t:TextField;
private var r:Sprite;
private var s:Sprite;
private var p:Sprite;
private var urlServer:String = "rtmp://media.iri.centrepompidou.fr/ddc_micro_record";
private var nc:NetConnection;
private var ns:NetStream;
private var ns2:NetStream;
private var mic:Microphone;
private var filename:String;
private var recordStopped:Boolean = false;
public function record_mic() {
// constructor code
Security.allowDomain("*");
Security.allowInsecureDomain("*");
t = _t;
r = _recordBtn;
s = _stopBtn;
p = _playBtn;
trace("t = " + t + ", r = " + r + ", s = " + s + ", p = " + p);
r.buttonMode = r.useHandCursor = s.buttonMode = s.useHandCursor = p.buttonMode = p.useHandCursor = true;
r.addEventListener(MouseEvent.CLICK, startRecord);
s.addEventListener(MouseEvent.CLICK, stopRecord);
p.addEventListener(MouseEvent.CLICK, playRecord);
}
private function startRecord(e:MouseEvent=null):void{
trace("startRecord nc = " + nc);
if (nc==null){
trace(" startRecord 2");
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler, false, 0, true);
nc.addEventListener(IOErrorEvent.IO_ERROR, errorHandler, false, 0, true);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler, false, 0, true);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, errorHandler, false, 0, true);
nc.connect(urlServer);
}
else{
publish();
}
}
private function errorHandler(e:*=null):void {
trace("errorHandler");
closeStream();
}
private function closeStream():void{
trace("closeStream");
if(ns!=null){
trace(" ns.close()");
ns.close();
ns = null;
}
}
private function netStatusHandler(event:NetStatusEvent):void {
trace("netStatusHandler : " + event.info.code);
switch (event.info.code) {
case 'NetConnection.Connect.Success':
publish();
break;
case 'NetConnection.Connect.Failed':
case 'NetConnection.Connect.Reject':
case 'NetConnection.Connect.Closed':
//closeStream();
break;
}
}
// send data over rtmp
private function publish():void {
trace("publish (ns==null && nc!=null && nc.connected) = " + (ns==null && nc!=null && nc.connected));
if(nc!=null && nc.connected) {
trace(" publish 2");
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler, false, 0, true);
ns.addEventListener(IOErrorEvent.IO_ERROR, errorHandler, false, 0, true);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, errorHandler, false, 0, true);
// informs the server to record what it receives
// in fact file name is passed as the user name (the server is meant to record everything it has to in a file named from the user name)
filename = "r_" + now();
trace("filename = " + filename);
ns.publish(filename, 'record');
mic = Microphone.getMicrophone(-1);
mic.rate = 22;
mic.gain = 50;
mic.setUseEchoSuppression(true);
ns.attachAudio(mic);
}
}
// stop the recording of audio to the stream
private function stopRecord(e:*=null):void{
trace("stopRecord (ns!=null) = " + (ns!=null));
if(ns!=null){
trace(" stopRecord 2");
recordStopped = true;
ns.play(false); // flushes the recording buffer
ns.close();
}
}
// plays back the audio that was recorded
private function playRecord(e:*=null):void{
trace("playRecord (ns!=null && recordStopped) = " + (ns!=null && recordStopped));
if(recordStopped){
trace(" playRecord 2");
ns2 = new NetStream(nc);
ns2.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler2, false, 0, true);
ns2.addEventListener(IOErrorEvent.IO_ERROR, errorHandler2, false, 0, true);
ns2.addEventListener(AsyncErrorEvent.ASYNC_ERROR, errorHandler2, false, 0, true);
ns2.play(filename);
}
}
private function netStatusHandler2(event:NetStatusEvent):void {
trace("netStatusHandler 2 : " + event.info.code);
}
private function errorHandler2(e:*=null):void {
trace("errorHandler 2");
closeStream2();
}
private function closeStream2():void{
trace("closeStream 2");
/*if(ns2!=null){
trace(" ns.close()");
ns2.close();
ns2 = null;
}*/
}
// Now in string
private function now():String{
var d:Date = new Date();
var m:uint = d.month + 1; // because Date.month begins at 0
return d.fullYear + (m<10?("0"+m):m) + (d.date<10?("0"+d.date):d.date) + (d.hours<10?("0"+d.hours):d.hours) + (d.minutes<10?("0"+d.minutes):d.minutes) + (d.seconds<10?("0"+d.seconds):d.seconds);
}
}
}
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic.swf
Binary file script/record_mic/record_mic.swf has changed
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/DOMDocument.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/DOMDocument.xml Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,377 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/LIBRARY/PlayBtn.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/LIBRARY/PlayBtn.xml Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/LIBRARY/RecordBtn.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/LIBRARY/RecordBtn.xml Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/LIBRARY/StopBtn.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/LIBRARY/StopBtn.xml Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/META-INF/metadata.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/META-INF/metadata.xml Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,55 @@
+
+
+
+
+ Adobe Flash Professional CS5
+ 2012-06-01T15:13:14+02:00
+ 2012-06-01T15:14:06+02:00
+ 2012-06-01T15:14:06+02:00
+
+
+ application/vnd.adobe.fla
+
+
+ xmp.iid:F77F11740720681188C6EA8C8D268D08
+ xmp.did:F77F11740720681188C6EA8C8D268D08
+ xmp.did:F77F11740720681188C6EA8C8D268D08
+
+
+
+ created
+ xmp.iid:F77F11740720681188C6EA8C8D268D08
+ 2012-06-01T15:13:14+02:00
+ Adobe Flash Professional CS5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/MobileSettings.xml
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/PublishSettings.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/PublishSettings.xml Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,202 @@
+
+
+
+ 1
+ 1
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ record_mic.swf
+ record_mic.exe
+ record_mic.app
+ record_mic.html
+ record_mic.gif
+ record_mic.jpg
+ record_mic.png
+ record_mic.mov
+ record_mic.smil
+
+
+ 0
+ 10,1,52,0;9,0,124,0;8,0,24,0;7,0,14,0;6,0,79,0;5,0,58,0;4,0,32,0;3,0,8,0;2,0,1,12;1,0,0,1;
+ 1
+ 1
+ record_mic.xfl_content.html
+ record_mic.xfl_alternate.html
+ 0
+
+ 550
+ 400
+ 0
+ 0
+ 1
+ 0
+ 0
+ 1
+ 1
+ 4
+ 0
+ 0
+ 1
+ 0
+
+ 1
+
+
+
+
+ 0
+ 0
+ 0
+ 80
+ 0
+ 0
+ 7
+ 0
+ 7
+ 0
+ 10
+ FlashPlayer10
+ 3
+ 1
+
+ .
+ CONFIG::FLASH_AUTHORING="true";
+ 0
+
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ record_mic
+ 2
+ 4
+ 4096
+ AS3
+ 1
+ 1
+ 0
+ 15
+ 1
+ 0
+ 4102
+ rsl
+ wrap
+ $(AppConfig)/ActionScript 3.0/rsls/loader_animation.swf
+
+
+ $(AppConfig)/ActionScript 3.0/libs
+ merge
+
+
+ $(AppConfig)/ActionScript 3.0/libs/11.0/textLayout.swc
+ rsl
+ http://fpdownload.adobe.com/pub/swz/tlf/1.0.0.595/textLayout_1.0.0.595.swz
+ http://fpdownload.adobe.com/pub/swz/crossdomain.xml
+ textLayout_1.0.0.595.swz
+
+
+
+
+ $(AppConfig)/ActionScript 3.0/libs/11.0/textLayout.swc
+
+ http://fpdownload.adobe.com/pub/swz/tlf/1.0.0.595/textLayout_1.0.0.595.swz
+ http://fpdownload.adobe.com/pub/swz/crossdomain.xml
+ textLayout_1.0.0.595.swz
+
+
+
+
+ 550
+ 400
+ 0
+ 4718592
+ 0
+ 80
+ 1
+
+
+ 1
+ 0
+ 1
+ 0
+ 0
+ 100000
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+
+
+ 550
+ 400
+ 0
+ 1
+ 1
+
+ 1
+ 0
+ 1
+ 0
+ 0
+
+ 128
+
+
+ 255
+
+
+
+ 550
+ 400
+ 1
+ 0
+ 0
+ 1
+ 0
+ 0
+ 1
+
+
+
+ 24 bits avec Alpha
+ 255
+
+
+
+ 550
+ 400
+ 1
+ 0
+
+
+ 00000000
+ 0
+ 0
+ 0
+ 0
+ 1
+
+
+
\ No newline at end of file
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/bin/SymDepend.cache
Binary file script/record_mic/record_mic/bin/SymDepend.cache has changed
diff -r 4928ecd06b44 -r 9c9db6355381 script/record_mic/record_mic/record_mic.xfl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/record_mic/record_mic/record_mic.xfl Fri Jun 01 17:46:57 2012 +0200
@@ -0,0 +1,1 @@
+PROXY-CS5
\ No newline at end of file