Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-02-2006, 02:09 AM   #1
jst1998
Registered User
 
Join Date: Jun 2006
Posts: 8
Default Controlling video download

I have a movie with two FLVPlayback components. What I would like to do is to have a video play in the first component and when the user stops that video, start playing another video in the second component.

The problem is that when I call stop() on the first component, it continues to download the flv file for that video until it has been completely loaded. Since I am starting to play another video in the second component, that causes a bandwidth problem because both videos are now loading.

Is there a way to explicitely stop a video from downloading?

Thanks
jst1998 is offline   Reply With Quote
Old 08-02-2006, 01:22 PM   #2
sleekdigital
I like pizza!
 
Join Date: Feb 2003
Location: PA
Posts: 1,310
Send a message via AIM to sleekdigital Send a message via MSN to sleekdigital Send a message via Yahoo to sleekdigital
Default

Maybe try setting the contentPath to null or an empty string?
__________________
SleekDigital Flash Blog
sleekdigital is offline   Reply With Quote
Old 08-02-2006, 06:25 PM   #3
jst1998
Registered User
 
Join Date: Jun 2006
Posts: 8
Default

That was my first thought as well, but it has no effect whatsoever.

It seems that once you open a netstream, the only way to stop it from downloading the flv, is to call close() on the stream, but once closed it can't be opened again to play another video. I just have a hard time believing that this is how it's supposed to work. What I'm trying to do doesn't seem like a very unusual use-case.
jst1998 is offline   Reply With Quote
Old 08-02-2006, 08:18 PM   #4
sleekdigital
I like pizza!
 
Join Date: Feb 2003
Location: PA
Posts: 1,310
Send a message via AIM to sleekdigital Send a message via MSN to sleekdigital Send a message via Yahoo to sleekdigital
Default

One thing to note about the FLV Playback component is that under the hood it uses "VideoPlayer" Objects. I believe if you use SMIL to make the player play multiple videos, the FLV Playback will use a new VideoPlayer Object for each new video that is requested. If you are not using SMIL, it seems that the FLV Playback always tries to use the same VideoPlayer Object unless you explicitly tell it to change. And I have found (at least in certian situations) that can cause problems similar to what you describe. Below is the method I use to make the player use a new VideoPlayer object each time I ask it to play a video. This method is part of a wrapper class I use so... player is a property that referes to the FLV Playback instance and nextVpIndex is a property that stores an integer to keep track of what VideoObject to use next. I don't use the VideoObject at index 0 because that one cannot be deleted.

Code:
   private function _playVideo(url:String) {

       if (player.activeVideoPlayerIndex > 0) {
           player.closeVideoPlayer(player.activeVideoPlayerIndex);
           delete player.getVideoPlayer(player.activeVideoPlayerIndex);
       }
       player.activeVideoPlayerIndex = ++nextVpIndex;
       player.visibleVideoPlayerIndex = nextVpIndex;
           player.play(url);

   }
__________________
SleekDigital Flash Blog
sleekdigital is offline   Reply With Quote
Old 08-03-2006, 11:39 PM   #5
jst1998
Registered User
 
Join Date: Jun 2006
Posts: 8
Default

This is an interesting solution. I didn't know that a videoplayer instance can actually be deleted. If this closes the stream correctly and executes fast enough, this might actually work for my scenario.

Thank You!
jst1998 is offline   Reply With Quote
Old 08-03-2006, 11:53 PM   #6
sleekdigital
I like pizza!
 
Join Date: Feb 2003
Location: PA
Posts: 1,310
Send a message via AIM to sleekdigital Send a message via MSN to sleekdigital Send a message via Yahoo to sleekdigital
Default

I hope it works out for you. Also, I just want to make a correction to my post... Using a SMIL file does not play multiple FLV's. It allows you to enter multiple FLV's and specifiy bitrates for each one so that you can deliver a different video base on the user's bandwidth. I'm not sure what situation I was thinking of, but it seems it is not using a SMIL file. At any rate, the code I posted has served me well when dealing with playing multiple FLV's with the FLV Playback component.
__________________
SleekDigital Flash Blog
sleekdigital is offline   Reply With Quote
Old 12-06-2006, 03:48 AM   #7
Registered User
 
Join Date: Dec 2006
Posts: 4
Default I tried it but to no avail

I'm having the same problem posted above. I'm trying to utilize the above script/function _playVideo. I can get it to make the video player play a new file but it does not solve the issue it says it does, for me at least. It still needs to load the entire file before accepting another contentpath, and it adds another problem, the player component controls become inactive, as if the player is playing but not recognizing that there is a new file. I did however remove the private portion of the code so that the function is no longer private. Is this necessary, and if so is this meant to be a seperate AS class file which is called externally? I tried reading up on it but didn't come up with much, specifically a reason for doing so, but I would love to defaulkt my knowledge to someone who has made this work. Anything is greatly appreciated. thx
emolen@emolen.net is offline   Reply With Quote
Old 12-06-2006, 04:08 AM   #8
anonymous
Banned by AS.org Staff
 
Join Date: Oct 2006
Posts: 1,524
Default

Here's what flashcomguru.com had to say about that...

I thought it would be easy enough to stop the flv downloading by killing the NetConnection or close the NetStream similar to how this would work using Flashcom. Unfortunately I had no success with that approach, the flv would continue downloading come what may.

Furtunately the workaround was suprisingly easy: try loading a non-existing flv. Here's the code I used:

ns.onStatus = function (info) {
if(info.code == "NetStream.Buffer.Full"){
my_video.attachVideo(null);
ns.pause();
ns.play("nonexist.flv");
}
};

This seems to do the trick quite nicely...


Worth a try...
anonymous is offline   Reply With Quote
Old 12-06-2006, 06:19 PM   #9
Registered User
 
Join Date: Dec 2006
Posts: 4
Default

seems to work but for some reason it acts very strange. I'm trying to target a my flvplayer component, but it doesn't replace the current file playing, rather it plays somewhere else, but replacing the file that is playing "who knows where" works very well, just can't seem to get it to load into the proper player. I haven't changed the path that worked prior to this code, so I really don't kow why it's acting up. I tried a few things, but no luck, anyone tried this before?
emolen@emolen.net is offline   Reply With Quote
Old 12-06-2006, 09:55 PM   #10
Registered User
 
Join Date: Dec 2006
Posts: 4
Default

I realize now your (anonymous) above post is particular to the video object, and not the flvplayback component. I've monkeyed around with sleekdigital's post but could not get it to work correctly, my problem lies in the if statement. I'm not exactly sure, but I'm only usinf a single flv component, and I have not been able to adapt the script.

any help is greatly appreciated.
thx
emolen@emolen.net is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Some Flash Video Converter Tools Compare terry117 Detention 7 05-18-2006 02:08 AM
flash video and progressive download and netConnection natronp ActionScript 2.0 5 08-09-2005 06:07 PM
Controlling video Ricewski Components 0 08-05-2004 03:29 PM
Controlling video SauloM ActionScript 1.0 (and below) 2 01-05-2003 01:34 PM


All times are GMT. The time now is 06:16 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.