Skip to main content
June 13, 2008
Question

netstream problem

  • June 13, 2008
  • 3 replies
  • 758 views
hi

wondered if someone could help with a problem that is rapidly turning into a disaster... We are currently developing a video uploading/viewing site,where users can create own channels and all that jazz. Built fully in flash. Now the problem we are having is this....

When a user is watching a video and decides to skip back through the site (to another channel as an example) BEFORE the stream has downloaded then the site hangs saying it cannot find the xml that it has been asked to load in(to make the channel display). After testing this works fine if the stream has fully loaded in. You can skip back and forth at your leisure. But if u decide to move before its streamed our function call to close the stream is called, but it doesn't physically close the connection (from the documentation this is how its meant to be). My question really is....is there a way to physically close that connection so that our site can continue to download additional data? any help on this would be great.

As reference we are using:

as3
and NOT using any straming server set up, purely http

This topic has been closed for replies.

3 replies

Participant
December 1, 2008
has anybody found solution - this "close()" ruins my script

thank you
August 13, 2008
I really want to know this one too.
Inspiring
June 14, 2008
Could you post the script - it will be easier to see if there is a problem?

For the semantics sake - http is not streaming per se but a progressive download.

In any case, it would be beneficial to see how you handle objects, especially their removal.
June 14, 2008
Hi

Ok here is a overview of how i have thing set up, i will try and keep it clear:)

>The site is fully flash based and uses swf address for navigation. So basicially all navigation is handled by a function that is called every time swf address changes

>When a user clicks a video a new instance of watch video class is created. That basically creates the netstream object, loads it in and plays it (amongst other stuff like creaitng panel movie clips and comments etc).


code form watch video class that creates stream:

private function connectStream():void {
stream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
client = new Object();
client.onMetaData = onMetaData;
stream.client = client;
video = new Video();
video.width = 380;
video.height = 285;
video.attachNetStream(stream);
video.x = 25;
video.y = 27;
stream.play(baseURL + "video.php?v=" + fileName);
trace("Trying to play:" + baseURL + "video.php?v=" + fileName);
videoDisplay.addChild(video);
_scrubbing = false;
addEventListener(Event.ENTER_FRAME, frameLoop);
_thumb.addEventListener(MouseEvent.MOUSE_DOWN, startScrub);
displayLoc.addEventListener(MouseEvent.MOUSE_UP, stopScrub);
displayLoc.parent.parent.watchVideoPlaying = true;


The last line sets up a variable that used to see if a video is playing when the user makes another navigational choice.

The follwoing code is conditional within the handleswfaddress function (that controls all navigation and removal and adding of data and screen elements):


if (watchVideoPlaying == true) {
if (channelName == "watchVideo") {
WatchVideo(currentDisplay).killStream();
} else {
DisplayLightbox(currentDisplay).killStream();
}
}

So bascially if a user is watching a video and than say clicks a channel to go to. The code sees that a video is playing and calls to kill the stream. That function looking like:


public function killStream(){

displayLoc.parent.parent.watchVideoPlaying = false;
stream.close();

}


Thats kind of it in its simplest sense. Now what happens is that the video stops playing when the close occurs, but the actual connection stays open. So when the channel data is trying to load in the swf just hangs an dhangs until eventually it says it cant open the xml.

Then say i close down the swf and retest the intial homepage doesnt load in again becasue the connection seems to be open and blocking any further connections. This then crashes flash. So when i go back in all is fine and the intial screen is loaded. Like i mentioned in the initial post, if all of the video is downloaded all is fine and works a dream. I can try and upload the entire code base if that will help, but its quite a beast:)

any help would be great as this is an absolute killer usability wise:|
Inspiring
August 14, 2008
I will try to look into it closer later. At this point - did you try to close connection and nullify it?

myNetConnection.close();
myNetConnection = null;