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…
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)