我目前有一个SWF应用程序,可以录制音频并将其保存到FMS。然后在Flash Professional中,我尝试使用FLVPlayback组件来播放录音,但它永远不会播放。
录音保存在此处:RootInstall/applications/myapp/streams/folder/audioFile.flv
然后我让我的 FLVPlayback 组件源查看rtmp://server-ip/myapp/streams/folder/audioFile
但我无法播放它。
我还复制了重新加载的音频文件并将其粘贴在 vod 应用程序中,但无法播放。当我尝试样本.flv视频时,它们起作用了。
以下是我在AS3中录制音频的方式:
nc.connect("rtmp://server-ip/myapp/folder");
...
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
mic = Microphone.getMicrophone();
ns.attachAudio(mic);
// start publishing
ns.publish("audioFile", "record");
录音方面的一切都是正确的,这是我试图阅读 FLV 的方式不正确。
根据上面的代码,这是我编码的player
面。
...
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://server-ip/myapp/folder");
private function netStatusHandler(event:NetStatusEvent):void
{
trace(event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success" :
//Connected Successfully
playLiveStream();
break;
case "NetConnection.Connect.Rejected" :
// Connection Rejected
break;
case "NetConnection.Connect.Failed" :
// The server may be down or unreachable
break;
case "NetConnection.Connect.AppShutDown" :
// The application is shutting down
nc.close();
break;
case "NetConnection.Connect.Closed" :
//Connection Closed
break;
}
}
private function playLiveStream():void {
nsPlay = new NetStream(nc);
nsPlay.client = this;
nsPlay.bufferTime = 0.1;
nsPlay.play("audioFile", -1);
}