On win10, flash player on firefox and chrome, microphone recording is not normal.
We found that after the upgrade to win10, flash page in the application, access to the recorded data is not normal. We install the latest version of the browser and the latest version of flash player, recording is not normal.
1. On firefox, can not get the microphone data, SampleDataEvent not working. (Debug version of flash player, recording normal)
2. On chrome, SampleDataEvent work, but some data loss.
3. On IE, normal recording.
Our application is to provide online conversation service, recording is not normal, we greatly affected.
We code a test application.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="100" minHeight="600" width="700" applicationComplete="abc()">
<fx:Script>
<![CDATA[
private var mic:Microphone = null;
private var timer:Timer = new Timer(1500,1);
private var loger:Boolean = false;
private var _buffer2:ByteArray;
private function abc():void{
log1.text = log1.text+"\n 20160114_1135";
}
private function init(event:MouseEvent):void{
log1.text = "";
log1.text = log1.text+"\n Capabilities.playerType:"+Capabilities.playerType;
log1.text = log1.text+"\n Capabilities.isDebugger:"+Capabilities.isDebugger;
log1.text = log1.text+"\n Capabilities.version:"+Capabilities.version;
log1.text = log1.text+"\n Capabilities.avHardwareDisable:"+new String(Capabilities.avHardwareDisable);
log1.text = log1.text+"\n Capabilities.hasAudio:"+new String(Capabilities.hasAudio);
log1.text = log1.text+"\n Capabilities.hasAudioEncoder:"+new String(Capabilities.hasAudioEncoder);
log1.text = log1.text+"\n Capabilities.hasMP3:"+new String(Capabilities.hasMP3);
log1.text = log1.text+"\n Capabilities.hasStreamingAudio:"+new String(Capabilities.hasStreamingAudio);
log1.text = log1.text+"\n";
log1.text = log1.text+"\n Microphone.isSupported:"+new String(Microphone.isSupported);
var mics:Array = Microphone.names;
log1.text = log1.text+"\n Microphone.size:"+new String(mics.length);
mic = Microphone.getMicrophone();
log1.text = log1.text+"\n Microphone.index:"+new String(mic.index);
log1.text = log1.text+"\n Microphone.name:"+mic.name;
this._buffer2 = new ByteArray();
this._buffer2.endian = Endian.LITTLE_ENDIAN;
mic.gain=66;
mic.codec = SoundCodec.NELLYMOSER;
mic.rate = int(txt_rate.text);
mic.setUseEchoSuppression(true);
mic.setSilenceLevel(1,-1);
mic.addEventListener(SampleDataEvent.SAMPLE_DATA,activity);
mic.addEventListener(StatusEvent.STATUS, onMicStatus);
log1.text = log1.text+"\n";
log1.text = log1.text+"\n activityLevel:"+new String(mic.activityLevel);
log1.text = log1.text+"\n codec:"+new String(mic.codec);
log1.text = log1.text+"\n enableVAD:"+new String(mic.enableVAD);
log1.text = log1.text+"\n encodeQuality:"+new String(mic.encodeQuality);
log1.text = log1.text+"\n framesPerPacket:"+new String(mic.framesPerPacket);
log1.text = log1.text+"\n gain:"+new String(mic.gain);
log1.text = log1.text+"\n index:"+new String(mic.index);
log1.text = log1.text+"\n noiseSuppressionLevel:"+new String(mic.noiseSuppressionLevel);
log1.text = log1.text+"\n rate:"+new String(mic.rate);
log1.text = log1.text+"\n silenceLevel:"+new String(mic.silenceLevel);
log1.text = log1.text+"\n silenceTimeout:"+new String(mic.silenceTimeout);
log1.text = log1.text+"\n useEchoSuppression:"+new String(mic.useEchoSuppression);
if(mic.enhancedOptions){
log1.text = log1.text+"\n enhancedOptions.autoGain:"+new String(mic.enhancedOptions.autoGain);
log1.text = log1.text+"\n enhancedOptions.echoPath:"+new String(mic.enhancedOptions.echoPath);
log1.text = log1.text+"\n enhancedOptions.isVoiceDetected:"+new String(mic.enhancedOptions.isVoiceDetected);
log1.text = log1.text+"\n enhancedOptions.mode:"+new String(mic.enhancedOptions.mode);
log1.text = log1.text+"\n enhancedOptions.nonLinearProcessing:"+new String(mic.enhancedOptions.nonLinearProcessing);
}
}
protected function button1_clickHandler(event:MouseEvent):void
{
log.text = "";
log0.text = "";
_buffer2.clear();
loger = true;
timer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
timer.start();
log1.text = log1.text+"\n muted:"+new String(mic.muted);
log1.text = log1.text+"\n SampleDataEvent: "+new String(mic.hasEventListener(SampleDataEvent.SAMPLE_DATA));
}
private function activity(event:SampleDataEvent):void {
if(loger){
event.data.position = 0;
log1.text = log1.text+"\n activity2:"+new String(event.data.length)+" "+new String(event.data.bytesAvailable);
while (event.data.bytesAvailable)
{
var v:Number = event.data.readFloat();
var engry:Number = v*0x7fff;
this._buffer2.writeShort(engry);
log0.text = log0.text+"\n"+v.toFixed(10);
log.text = log.text+"\n"+engry.toFixed(0);
}
}
}
public function onTimerComplete(event:TimerEvent):void {
loger = false;
timer.removeEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
}
public function onMicStatus(event:StatusEvent):void
{
log1.text = log1.text+"\n onMicStatus "+event.code;
}
protected function button2_clickHandler(event:MouseEvent):void
{
log.text = "";
log0.text = "";
}
protected function button3_clickHandler(event:MouseEvent):void
{
var file:FileReference = new FileReference();
file.save(this._buffer2, "r2.wav");
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:TextArea x="266" y="43" width="116" height="550" id="log"/>
<s:TextArea x="407" y="43" width="206" height="550" id="log0"/>
<s:TextArea x="10" y="43" width="235" height="550" id="log1"/>
<s:Button x="205" y="14" label="Record" click="button1_clickHandler(event)"/>
<s:Button x="279" y="14" label="Clear" click="button2_clickHandler(event)"/>
<s:Button x="522" y="14" label="Save" click="button3_clickHandler(event)"/>
<s:TextInput x="10" y="14" width="81" text="44" id="txt_rate"/>
<s:Button x="127" y="14" label="Init" click="init(event)"/>
</s:Application>
