ブラウザから rtmp 経由で音声をストリーミングしようとしています。そのためにフラッシュAPIを使用します。そして、すべてが localhost で完璧に動作します。専用サーバーでブラウザからサウンドを録音しようとすると、クライアント(私)がブラウザでマイクからのキャプチャを許可していない( microphone.mutedがtrue )と表示されますが、後で許可しました最初のリクエストであり、設定で引き続き許可されています。何か案が?
<?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>