Reputation: 1688
I have video streaming from the server, and later on I want to add another one just side by side. thats all good, I done that. Now my problem comes when i want to remove video. I manage to remove it from display, but I can hear that video is still playing in the background. So how do I can stop streaming that video? Here is my code for setting up the video:
ns = new NetStream(connection);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play(item[1].toString() + ".flv");
video = new Video();
video.attachNetStream( ns );
video.width = 160;
video.height = 120;
videoWrapper = new UIComponent();
videoWrapper.addChild( video );
videos.addElement( videoWrapper );
and here is for removing
videos.removeElement(myVideos[p][1]); // myVideos[p][1] is a reference of videoWrapper
Upvotes: 3
Views: 20146
Reputation: 2135
On a normal video object, do not call attachNetStream(null)
, because AS3, later will not let clear the last video frame from the video with .clear()
Looks like a bug.
Use ns.close()
, then use vid.clear()
, so that the video object can be transparent again.
On StageVideo, this is different:
You can call vid.attachNetStream(null)
, it will remove the last frame too from the stagevideo.
Be careful, it will not stop the playing itself. You have to call ns.close();
Upvotes: 4
Reputation: 4432
You can drop the connection by calling video.attachNetStream(null)
, or close the stream with ns.close();
It's probably best to do both.
Upvotes: 6