I'm developing a one-on-one video chat application using Wowza. After the remote client stops publishing, I'm disconnecting the incoming NetStream. Here's a gist of my code:
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;
}
}
Here's the problem: after the NetStream.Play.UnpublishNotify event fires and I close the incoming stream, I receive the following runtime error:
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound
If I comment out the removeEventListener() line in incomingStreamHandler() above, I see that NetStream.Play.UnpublishNotify is followed by NetStream.Play.StreamNotFound. But why does this event still fire even after I close the incoming NetStream?
(Initially, I was disconnecting the incoming stream on NetStream.Play.StreamNotFound instead of NetStream.Play.UnpublishNotify but I found that the former event doesn't always fire so I want to rely on NetStream.Play.UnpublishNotify instead.)