我正在使用Wowza開發一對一視頻聊天應用程序。遠程客戶端停止發佈後,我正在斷開傳入的NetStream。下面是我的代碼要點:NetStream在關閉後接收事件
incomingStream = new NetStream(netConnection);
incomingStream.addEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
incomingStream.play("media");
private function incomingStreamHandler(event:NetStatusEvent):void
{
trace(event.info.code);
if (event.info.code == "NetStream.Play.UnpublishNotify")
{
incomingStream.close();
incomingStream.removeEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
incomingStream = null;
}
}
這裏的問題:NetStream.Play.UnpublishNotify事件觸發後,我關閉輸入流,我收到以下運行時錯誤:
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound
如果我註釋掉上面的incomingStreamHandler()中的removeEventListener()行,我看到NetStream.Play.UnpublishNotify後面跟着NetStream.Play.StreamNotFound。 但是爲什麼即使在關閉輸入的NetStream之後,這個事件仍然會觸發?
(起初,我在斷開的NetStream.Play.StreamNotFound代替NetStream.Play.UnpublishNotify輸入流,但我發現,前者的事件並不總是火,所以我想依靠NetStream.Play.UnpublishNotify )