View comments | RSS feed

NetStream.close()

Availability

Flash Player 7.

Note: This method is also supported in Flash Player 6 when used with Flash Communication Server. For more information, see the Flash Communication Server documentation.

Usage

my_ns.close() : Void

Parameters

None.

Returns

Nothing.

Description

Method; stops playing all data on the stream, sets the NetStream.time property to 0, and makes the stream available for another use. This command also deletes the local copy of an FLV file that was downloaded using HTTP.

Example

The following onDisconnect() function closes a connection and deletes the temporary copy of video1.flv that was stored on the local disk when you click the button called close_btn:

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video1.flv");

close_btn.onRelease = function(){
   stream_ns.close();
};

See also

NetStream.pause(), NetStream.play()

Comments


Francis Cheng said on Aug 2, 2004 at 10:13 AM :
Although Flash Player will delete the local copy of the FLV file that it creates, a copy of the video may persist in the browser's cache directory. If prevention of caching is required, use Flash Communication Server MX.
recoveredfromflashMX2004 said on Aug 4, 2004 at 3:40 PM :
No screen name said on Apr 28, 2004 at 5:28 PM :

In my tests the local copy of an FLV file that was downloaded using HTTP is NOT deleted. Is there something missing here?


No screen name said on May 7, 2004 at 2:27 AM :

I just found this function didnt work at all - i could replace the stream but the audio from the last video was still playing


mrkandersn said on May 13, 2004 at 1:19 PM :

I've also been unable to get NetStream.close() to work as advertised. It
seems the only way to get rid of a streamed flv is to stream another.


jeremedia said on May 20, 2004 at 4:35 PM :

NewStream.close() doesn't even stop the video from streaming in. In my
tests, I have been unable by any method to stop a video file from
downloading. Very, very frustrating. If a viewer decides not to watch a
certain video and navigates away from that video, the video continues to
download, slowing the download of all other files.


No screen name said on Jul 11, 2004 at 6:59 AM :

Seems to be a bug then because I came here because of having the same problems

s
shimi2 said on Oct 21, 2004 at 4:45 PM :
So far, NetStream.close() works in my tests. One thing to try: add a call to Video.clear() to clear the video object, after the NetStream.close() method.
I'll continue to investigate. Thanks for your feedback.
twodotone said on Nov 12, 2004 at 2:06 AM :
calling a clear on the video instance doesn't do the job.
i even tried this

netStr.close();
videoplayer.clear();
netStr=0;
netConn=0;

so far, destroying every reference to that stream (even the local
connection and the NetStream object itself) doesn't solve the problem.
the only way to destroy the stream is to close the browser window (at
least on mac), while on a pc we tested yesterday, we had to restart the
system.

i even tried (even though not documented) to close the netConnection
object using a .close() method on it.
of course no benefit.
on director, i closed connections setting them to 0 (zero), but this
doesn't affect this player "bug"

hope to find a solution, since we need to deliver this site in 10 days

:(

cheers.twodotone
shimi2 said on Nov 12, 2004 at 3:21 PM :
Hi - Please see this tech note. While you might not be using Flash Com server, the article has some suggestions for testing the NetSTream object.
http://www.macromedia.com/support/flashcom/ts/documents/comms_apps.htm
No screen name said on Nov 17, 2004 at 9:22 AM :
Sorry for this question...I'm a bit new to this. Do you need to have/use a Flash Comm Server in order to use the NetStream Object and properties? If not, where do you place the code in order get the flv playing and have the ability to control it (in any movie clip > timeline?).

I've been having the same problems with everyone else. The FLV still plays when you unload a movie clip with the flv or do a number of actionscript "tricks" to get it to stop.
shimi2 said on Nov 17, 2004 at 10:01 AM :
In response to No Name's post at Nov 17, 2004 at 9:22 AM:
You can use the NetStream object with Flash Player 7 or later. You don't need Flash Communication Server unless you publish to Flash Player 6. Flash Communication Server does offer more functionality with the NetStream object, however.
shimi2 said on Nov 17, 2004 at 10:04 AM :
Hi - I'd like to give you an update on the problem with stopping playback of streaming FLVs.
The Flash Player QA team reproduced the problem, filed a bug, and is working to resolve it.
Thanks to all who reported the issue.
FlismFlazim said on Nov 19, 2004 at 10:04 AM :
In summary, calling NetStream.close() fails to stop the download of FLVs on Mac OS 10.x with Safari only. This does not happen on Mac IE, Firefox, or Mozilla or any Windows Players. Jumping to another URL or closing the browser instance terminates the downloading.

Primary users that may experience this problem is being on a slow connection with large videos. Most users on faster connections or small videos will not be affected. Macromedia Flash Player is aggressively working with Apple to resolve this issue.

Macromedia Flash Player
shimi2 said on Mar 31, 2005 at 11:22 AM :
Here's an update on the close() issue:
Apple is also looking into the problem.
Another thing to watch out for is when you are using a "proxy" based bandwidth profiler. The proxy may cause the close connection call to fail. We recommend using profilers that intercept or sniff packet transmission.
PulkitGuptz said on Jul 6, 2005 at 12:29 AM :
I am trying to build a Flash Video Player. All works fine till the video is loaded. Once i try to play the video that is laready loaded. It doesnt read the Duration metaData.. I tried to clear the video with NetStream.close(); but it just didnt do nething.. IS THERE A WAY TO DELETE THE VIDEO COMPLETELY FROM THE CACHE? Or it remains a bug?
nima15 said on Aug 7, 2005 at 6:21 AM :
Since its been a year after this issue I was wondering if we have a final solution for it?

I am experiencing the same problem it almost makes FLV useless....

I am loading an external SWF into my main swf, this external swf carries a FLV video. I call this SWF by loadmovienum and then when I want to turn it off I call it off by unloadmovienum. But if I call it off in the middle of the flv the sound of this FLV stream remains On! until I quite the browser!!! How can I unload this FLV so that the video and the sound dissapear together!!!
bharv said on Aug 22, 2005 at 2:51 PM :
If you are using the media display component and the media controller component together, you must link the controller to the display and not the other way around.

I had the display linked to the controller and whenever I tried to unload the flv, the sound would continue to play. In addition I could not reload the flv.

By linking the controller to the movie instead the movie to the controller this solved my problem.
dfunk007 said on Aug 25, 2005 at 3:05 PM :
Hey bharv. How did youlinnk the controller to the movie instead of the
movie to the controller? Is there and script involved in that process and is
there any other unload script you are using to achieve this. Any help would
rock!
kfur said on Oct 27, 2005 at 5:07 PM :
I've noticed that NetStream.close(); doesn't work in my test's either. I can get it to work on a progressive flv but not on a rtmp streamed flv. I have noticed that you can however do it from the server side using flash com and a main.asc file.
kfur said on Oct 28, 2005 at 10:40 AM :
Another way around the persistent sound after unloading a flv is to only
use the video object with your own controls.
video_ns.play
video_ns.pause
video_ns.seek
( No stop is available. ) seek(0); and pause(); aproximate it.

Then create a seperate sound object to deal with the sound.

I found that the media components were heavy in file size and quirky.
Flash 8 fixes a lot of the issues in V2 components but they are ONLY
available to users who have the Flash 8 player installed. Try it again in
six months once 80% saturation is completed.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001594.html