08-02-2006, 02:09 AM
|
#1
|
|
Registered User
Join Date: Jun 2006
Posts: 8
|
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
|
|
|
08-02-2006, 01:22 PM
|
#2
|
|
I like pizza!
Join Date: Feb 2003
Location: PA
Posts: 1,310
|
Maybe try setting the contentPath to null or an empty string?
|
|
|
08-02-2006, 06:25 PM
|
#3
|
|
Registered User
Join Date: Jun 2006
Posts: 8
|
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.
|
|
|
08-02-2006, 08:18 PM
|
#4
|
|
I like pizza!
Join Date: Feb 2003
Location: PA
Posts: 1,310
|
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);
}
|
|
|
08-03-2006, 11:39 PM
|
#5
|
|
Registered User
Join Date: Jun 2006
Posts: 8
|
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!
|
|
|
08-03-2006, 11:53 PM
|
#6
|
|
I like pizza!
Join Date: Feb 2003
Location: PA
Posts: 1,310
|
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.
|
|
|
12-06-2006, 03:48 AM
|
#7
|
|
Registered User
Join Date: Dec 2006
Posts: 4
|
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
|
|
|
12-06-2006, 04:08 AM
|
#8
|
|
Banned by AS.org Staff
Join Date: Oct 2006
Posts: 1,524
|
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...
|
|
|
12-06-2006, 06:19 PM
|
#9
|
|
Registered User
Join Date: Dec 2006
Posts: 4
|
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?
|
|
|
12-06-2006, 09:55 PM
|
#10
|
|
Registered User
Join Date: Dec 2006
Posts: 4
|
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
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:35 AM.
///
|
|