我在FMS 4.5 (也尝试使用FMS 5)实现HLS时遇到了一个问题。我正在关注这篇文章http://help.adobe.com/en_US/flashmediaserver/devguide/WSd391de4d9c7bd6 09-52e437a812a3725dfa0-8000.html。
当我使用FMLE (Flash媒体实时编码器)将直播流发布到livepkgr应用程序时。它在我的ios设备上运行得很好。但是当我使用Flex4.7代码发布时,声音没有发出,甚至视频在ios设备上过了一段时间后也停止播放。
任何人都知道为什么会发生这种情况。任何帮助都将不胜感激。
我正在添加要审查的代码。(您可以创建一个flex项目,并在creation_complete事件上调用"windowedapplication1_creationCompleteHandler".并将FMS_serverIp更改为reall fms服务器ip。
<fx:Script>
<![CDATA[
import mx.core.UIComponent;
import mx.events.FlexEvent;
var nc:NetConnection;
var cam:Camera;
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void{
var ui:UIComponent = new UIComponent();
var v:Video = new Video();
ui.addChild(v);
this.addElement(ui);
this.cam = Camera.getCamera();
this.cam.setMode(320, 240, 30);
this.cam.setQuality(0, 100);
v.attachCamera(this.cam);
this.nc = new NetConnection();
this.nc.client = this;
this.nc.addEventListener(NetStatusEvent.NET_STATUS, startStream);
this.nc.connect("rtmp://FMS_serverIp/livepkgr/");
}
protected function startStream(event:NetStatusEvent):void
{
switch (event.info.code){
case "NetConnection.Connect.Success":
trace("init stream "+this.nc.uri);
var s:NetStream = new NetStream(this.nc);
var h264Settings:H264VideoStreamSettings;s
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.MAIN, H264Level.LEVEL_1_2);
h264Settings.setMode(320,240,30);
s.videoStreamSettings = h264Settings;
s.client = this;
s.addEventListener(NetStatusEvent.NET_STATUS, checkMediaStatus);
s.attachCamera(this.cam);
s.attachAudio(Microphone.getMicrophone());
s.publish("livestream?adbe-live-event=liveevent");
trace("Stream is publishing ...");
break;
}
}
protected function checkMediaStatus(event:NetStatusEvent):void
{
trace("Stream status "+event.info.code);
}
]]>
</fx:Script>发布于 2014-04-14 19:16:25
您的NetStream对象很可能被垃圾收集器吃掉了。尝试将其声明为字段。相机也是如此。
https://stackoverflow.com/questions/20663370
复制相似问题