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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
// FONCTIONS
//---------------------------------------------------------------------
// Popup de configuration micro
function popUp(){
getURL("javascript:void(window.open('config.html','_blank','width=350,height=250,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=no,left=30,top=30'))");
}
//---------------------------------------------------------------------
// Initialisation micro et flux
function init() {
// Microphone
monMic = Microphone.get();
if (monMic.gain>60) {
monMic.setGain(60);
}
// flux sortant
out_ns = new NetStream(nc);
out_ns.attachAudio(monMic);
// flux entrant
in_ns = new NetStream(nc);
}
//---------------------------------------------------------------------
//Enregistrement
function startRecord(){
out_ns.publish(login, "record"); // !!! login = variable online
btn_rec._visible = false;
btn_stopRec._visible = true;
clip_recording._visible = true;
btn_compare.setEnabled(false);
}
//---------------------------------------------------------------------
// FCSConnector
//---------------------------------------------------------------------
// Initialisation de la connection
var nc = new FCSConnector(); //voir FCSConnector.as
nc.connect("rtmp://localhost/oflaDemo", login);
// Gestion des event
nc.addEventListener("onConnect", this);
nc.addEventListener("onReject", this);
nc.addEventListener("onClose", this);
nc.addEventListener("onFail", this);
function onConnect(ev) {
trace("Connect passed");
init();
}
function onReject(ev) {
trace("connect rejected");
}
function onClose(ev) {
trace("connect closed");
}
function onFail(ev) {
trace("connect fail");
}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//--INITIALISATION GENERALE--
// Organisation des boutons
btn_pause._visible = false;
btn_stopRec._visible = false;
clip_recording._visible = false;
// Déclaration de variables
mySoundPosition=_root.mySound.position/1000;
mySoundDuration=_root.mySound.duration/1000;
mySound = new Sound();
mySound.loadSound("sound.mp3", false); // !!! "sound.mp3" devient une variable online
//--------------------------------------------------
// Bouton PLAY
btn_play.onRelease = function(){
btn_pause._visible = true;
btn_play._visible = false;
if (mySoundPosition == 0) {
mySound.start();
} else {
mySound.start(mySoundPosition); //recupération de la variable de position
}
mySound.onSoundComplete = function() {
btn_pause._visible = false;
btn_play._visible = true;
}
}
// Bouton PAUSE
btn_pause.onRelease = function(){
btn_pause._visible = false;
btn_play._visible = true;
mySoundPosition = _root.mySound.position/1000; //position du son lors de la "pause"
_root.mySound.stop();
};
// Bouton Record
btn_rec.onPress = function() {
if(monMic.muted == true){
popUp();
}
else
{
startRecord();
}
}
// Bouton Compare
btn_compare.onPress = function() {
in_ns.play(login);
};
// Bouton Stop
btn_stopRec.onPress = function() {
out_ns.close();
btn_rec._visible = true;
btn_stopRec._visible = false;
clip_recording._visible = false;
btn_compare.setEnabled(true);
}; |
Partager