I’ve been stuck on this for ages now. I have a player that streams an .flv file but I need it to have a progress bar so people can see how much has loaded while its playing…
your problem may be in the this._parent._parent bit even though it should work theoretically. Could you possible use an aboslute target instead? That might help.
The best way I have found is to setup an onEnterFrame function and test the bytes loaded against the bytes total of the FLV. You setup a movie clip and based on the percentage loaded, scale the movie clip’s ._xScale until you reach 100%. Since this is done on an enterFrame setup it will updated consistentaly based on your frame rate.
_root.onEnterFrame = function () {
//prossessor speed conserved by setting main movie's frame rate to 1.0 fps.
//load bar updated 1X / second
var vidBytesLoaded = netStream.bytesLoaded;
var vidBytesTotal = netStream.bytesTotal;
if (vidBytesLoaded < vidBytesTotal) {
var vidPercentLoaded = Math.floor((vidBytesLoaded/vidBytesTotal) * 100);
_root.percentBar._xscale=vidPercentLoaded;
status1.text="Percent = " + vidPercentLoaded + " Loaded..."; //debug
status2.text=netStream.bytesLoaded + " bytes of " + netStream.bytesTotal;
}
}
Have tried all your code dude and to no avail… I am using a media component to stream the FLv and have seperate controlelrs for scubbing the time line, volume etc.
All I want is a progress bar that follows the stream (gradually moving to 100%) whilst the play button gently moves along…
You need to make sure your using the “Embedded Video” component. The other components such as media playback will not work with that code. If you indeed using the Embedded Video component then post again to send me an e-mail reminder and I’ll try to post the flash file with working code.
The media components are composed of the Embedded Video object, I believe.
Unless you are using something like FlashComm you won’t get true streaming.
If you are using only Flash and no server that has streaming abilities you are only doing virtual streaming. This means that the video only loads to it’s set buffer and then starts playing. This does seem like streaming, but it’s not true streaming. You can test this if you have a progress bar similar to the Media Playback or Media Controller components and try clicking ahead of the current playtime. If you can advance the vid doing this it means either of two things: the video is true streaming or the video is virtual streaming but the entire video has loaded ( been cached ).
So if you want to duplicate or make your own Media Display/ Controller/ Playback components you must use the Embedded Video object and define all your connections using the NetConnnections and NetStream objects.
To add an Embedded Video object to your stage, in your library click the little icon on the right side of the panel’s title bar and select New Video.
I’ve created a flash file that you can plug any movie into. It has the progress bar setup so regardless of the movie size it will update at the rate of your fps. 12 fps is usually good but it could be anything.
Here’s some more insight on true streaming versus progressive streaming. The only way to avoid a progressive stream (where the file loads to your computer) is to use flash communications server. This is just like a windows media file. Without a streaming server you will get a progressive download (downloads and caches as it plays). This is not a limitation, but a choice. You face the same situation with RealVideo, Windows Media, etc… No streaming server, no true stream.
Thats great and works really well…however… the video player I have made uses the Media Component and has a scrub bar, play/pause buttons and a volume bar. As soon as I swap the media component for an embedded video that uses the [color=SandyBrown]my_Video.attachVideo(netStream);[color=Black] I lose all the functionality but gain a progress bar.
This is pretty weird… could you have a quick look?
That’s the catch with the embedded video component. You’ve got to create your own controllers. It’s a good trade though, it’s not to crazy difficult to do. I highly recommend taking a look at a complete project created by the macromedia guys. It has all the source files and video files to play around with. Here’s the link:
You’ve got me thinking now. I think my solution will work with these two modifications. Instead of loading the video into an embedded video component you use the media playback component. Then to load a movie into that dynamically you use the media.setMedia() – Then my loader bar code should work by testing the bytes loaded / total with the media.bytesLoaded and media.bytesTotal.
Yeah this is pretty groovy. All you need is this code in an actions frame.
videoDisplay.setMedia("http://yoursite/yourmovie.flv);
//==========================================================
//=============Loading Percent Bar Code=====================
listenerObject = new Object();
listenerObject.progress = function(eventObject){
// insert your code here
//trace("loading");
var vidBytesLoaded = videoDisplay.bytesLoaded;
var vidBytesTotal = videoDisplay.bytesTotal;
if (vidBytesLoaded <= vidBytesTotal) {
var vidPercentLoaded = Math.floor((vidBytesLoaded/vidBytesTotal) * 100);
_root.percentBar._xscale=vidPercentLoaded;
percent.text= vidPercentLoaded + "% Loaded";
}
}
videoDisplay.addEventListener("progress", listenerObject)
how did you get this worked out, did you end up using the one that you were building or did you buy one. i am up against the wall with this same project and am thinking about buying one. i just need to figure out a solution to my own video problem.
it is on this site www.roddyonline.com the videos are on the bottom of the homepage.
the video has a preloader that just loads lite 30 percent of the movie but that seems to mess up the audio and video they are off a second or two.
Yeah I got it working… I’ll post a flash file in a little bit… However the first problem which is a BIG issue… one I spent months on is the audio sync. You mentioned the sync problems in your post and I noticed it when on your site. Are you using Cleaner XL, or After Effects, or really any program in conjuction with the Flash Exporter? I would venture to say you’re not going to get sync with the Flash Exporter… I wasted forever on this. I about gave up until FlixPro came into my life. This is THE encoder to have for FLV video files.
Get me some feedback as to how your encoding your vid and I’ll try to get a .fla posted with progress bar and video position indicator… The flv files have to be striped with the timecode for the position indicator to work… (which the flash exporter does or flix or cleaner… etc…) But I don’t think those methods will give you sync… An issue I’m planning on telling Macromedia about… not very happy about their attempt. It’s close, but not enough to release as a “working product”.
what i am doing now is totally the wrong way i am sure. what i am doing is taking quicktime into the new sorencen squeeze and then that makes my flv. then i am taking the flv and bringing it into a flash file so i can mask it and put a preloader on it.
i think that i would be better off just keeping the flv outside of a flash file and not importing it like i am doing now. that is why i am interested in this progress bar way, because it seems like what i can do is put the flv on my server and then link to it