NetStream.publish Webcam to FMS working in standalone player, but not in browser

这一生的挚爱 提交于 2019-12-06 09:26:31

Ok, I found what my problem is here: I declare the reference to the stream variable inside the connectCamera function:

private function connectCamera(ev:Event = null):void {
    var stream:NetStream = new NetStream(connection);
}

So stream is only declared inside the scope of that function. This doesn't seem to be a problem in the standalone player, but it is in the browser plugin. The browser plugin seems to do a much more thourough job on the garbage collector, garbage collecting my stream after the function has executed. So what I have to do is declare the stream variable outside of the function scope, inside the class scope.

var stream:NetStream;
private function connectCamera(ev:Event = null):void {
    stream = new NetStream(connection);
}

You should always declare stuff that you need later as a field on your class, and not inside a function. You just never know when GC might clean up that stuff.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!