I'm trying to stream audio from browser via rtmp. I use flash api for that. And everything works perfect on localhost. When I'm trying to record the sound from browser on dedicated server it's says to me, that the client (me) haven't allowed the capturing (microphone.muted is true) from my microphone in browser, but I did allow it after first request and it's still allowed in the settings. Any idea?
<?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="500" minHeight="350" creationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
private var streamer:String;
private var file:String;
private var microphone:Microphone;
private var connection:NetConnection;
private var stream:NetStream;
private var h264Settings:H264VideoStreamSettings;
private function toggleFeedListener():void {
if(toggleFeed.label == 'Start Feed') {
toggleFeed.label = 'Stop Feed';
stream.publish(file, 'live');
} else {
toggleFeed.label = 'Start Feed';
stream.close();
}
}
private function stopStream():void {
if(toggleFeed.label != 'Start Feed') {
toggleFeed.label = 'Start Feed';
stream.close();
}
}
private function startStream():void {
if(toggleFeed.label == 'Start Feed') {
toggleFeed.label = 'Stop Feed';
stream.publish(file, 'live');
}
}
private function getActivityLevel():int {
return microphone.activityLevel;
}
private function initListeners():void {
ExternalInterface.addCallback("toggleFeedListener", toggleFeedListener);
ExternalInterface.addCallback("startStream", startStream);
ExternalInterface.addCallback("stopStream", stopStream);
ExternalInterface.addCallback("getActivityLevel", getActivityLevel);
}
private function log(message:String):void
{
trace (message);
if (ExternalInterface.available)
{
ExternalInterface.call('console.log', message);
}
}
private function netStatusHander(event:NetStatusEvent):void {
switch(event.info.code) {
case 'NetConnection.Connect.Success':
stream = new NetStream(connection);
stream.attachAudio(microphone);
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_1_2);
stream.videoStreamSettings = h264Settings;
break;
}
}
private function init():void {
streamer = FlexGlobals.topLevelApplication.parameters.streamer;
file = FlexGlobals.topLevelApplication.parameters.file;
if(file == null) {
Alert.show('Missing flashvars: file');
return;
}
if(streamer == null) {
Alert.show('Missing flashvars: streamer');
return;
}
microphone = Microphone.getEnhancedMicrophone();
log (String(microphone.muted));
log (microphone.name);
log (String(microphone.index));
initListeners();
microphone.setSilenceLevel(0);
//microphone.codec = "Speex";
microphone.encodeQuality = 10; // 0 - 10
connection = new NetConnection();
connection.connect(streamer);
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHander);
}
]]>
</fx:Script>
<s:Panel x="0" y="0" width="100%" height="100%" title="RTMP Publisher">
<s:controlBarContent>
<s:Button label="Start Feed" id="toggleFeed"></s:Button>
<s:Spacer width="100%" height="100%"/>
</s:controlBarContent>
</s:Panel>
</s:Application>