|
-
Progressive Streaming Question
I've found how to load an flv file into my flash file and then have it load progressively. What I'm wondering now, is whether or not there is a way to display the progress of the download. I have a 25MB video and it starts very quickly on my fast connection, but I know that it's not fully loaded. Is there a way that I can display a progress bar, similar to what Quicktime does with its' hinted streams, where the loaded bar fills up as the video loads and another color bar displays where the play head is at on the video. I've tried to use the bytesLoaded and bytesTotal, but I don't completely understand how to use them yet.
Any help is appreciated.
Thanks,
FE
-
Ok, I've figured out part of it. Here's what I did. On the main timeline, I put my netStream code...
Code:
my_nc = new NetConnection();
my_nc.connect(null);
my_ns = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.setBufferTime(20);
my_ns.play("reel.flv");
Then, on my timeline I added a movieclip with a graphic inside, that I animated for 100 frames. On the movieclip, I added this code...
Code:
onClipEvent(enterFrame) {
bytesTotal = _root.my_ns.bytesTotal;
bytesLoaded = _root.my_ns.bytesLoaded;
perLoaded = Math.floor(bytesLoaded/bytesTotal * 100);
this.gotoAndStop(perLoaded);
}
This displays a percent loaded meter. Then, underneath it I duplicated the movieclip and changed its color. I then removed the percent loaded code and added this...
Code:
onClipEvent(enterFrame) {
curTime = _root.my_ns.time;
perLoaded = Math.floor(curTime/_global.totalTime * 100);
this.gotoAndStop(perLoaded);
}
This displays a meter showing where the current playhead is. However, it depends on a variable called _global.totalTime, which needs to be set to the total length in seconds of the movie. For now, I manually set the variable with...
Code:
_global.totalTime = 61.16;
That works alright, but I'd prefer to have the value dynamic, rather than static. I tried using metadata, but the movie didn't like this code...
Code:
my_ns.onMetaData = function(obj) {
_global.totalTime = obj.duration;
_global.dataRate = obj.videodatarate;
_global.audioRate = obj.audiodatarate;
_global.createDate = obj.creationdate;
}
Said thaat I had an actionscript error. Said that there was no property with the term onMetaData. Is there a way I can fix this?
A more important issue that I need to address, is when the movie is loading, it does not seem to preload enough of the movie to play on all connections. Is the only reason it's preloading prior to playing because of the fact that I put a buffer on the movie? I'd like to have a dynamic buffer, based on how fast the users' connection speed is, but I'm guessing that's not an easy thing to do.
Anyway, enough of my babble. If anyone has any input, I'd love to hear it.
Thanks,
FE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|