Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Flash Media Server

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-10-2004, 04:41 PM   #1
mpol777
Registered User
 
mpol777's Avatar
 
Join Date: Jun 2001
Posts: 247
Default netStream preloading

I must be spacing out. What I'm trying to do is get the percent loaded on a netStream load so I have control over when I kick off the play. Problem is with the following code bytesLoaded and bytesTotal both return as 0.

I don't want to use the setBufferTime method since that doesn't translate into how much is loaded and the size of the videos can vary greatly. So what am I missing here?


PHP Code:
// attach front video
    
nc = new NetConnection();
    
nc.connect(null);
    
ns = new NetStream(nc);

    
checkFrontProgress = function(videoRef) {
    
debug("videoRef: "+videoRef);
    
fbl videoRef.bytesLoaded;
    
fbt videoRef.bytesTotal;
    
debug("Loaded: "+fbl);
    
debug("Total: "+fbt);
    
fper Math.floor(fbl/fbt*100);
    if (
fper >= 20) {
        
clearInterval(frontInterval);
        
videoRef.play(frontVideo);
    }
    }

    
frontViewVideo.attachVideo(ns);
    
frontInterval setInterval(checkFrontProgress,100,ns); 

Last edited by mpol777; 05-10-2004 at 04:45 PM..
mpol777 is offline   Reply With Quote
Old 05-10-2004, 06:34 PM   #2
mpol777
Registered User
 
mpol777's Avatar
 
Join Date: Jun 2001
Posts: 247
Default

I think I have this thing figured out. Below is a hack, but a working hack nonetheless. It turns out the pause() method toggles the play status. play() starts the whole thing over.

PHP Code:
 // attach front video
    
fnc = new NetConnection();
    
fnc.connect(null);
    
fns = new NetStream(fnc);
    
frontViewVideo.attachVideo(fns);

    
fns.play(frontVideo);
    
fns.pause();
    
preloaded false;
    
    function 
checkFProgress() {
    
fbl fns.bytesLoaded;
    
fbt fns.bytesTotal;
    
fper Math.floor((fbl/fbt)*100);
    
debug(fper+"%");
    if (
fper >= 20) {
        
clearInterval(fInterval);
        
preloaded true;
        
fns.pause();
    }
    }

    
fns.onStatus = function(infoObject) {
    
debug("Status (NetStream)");
    
debug("Level: "+infoObject.level);
    
debug("Code: "+infoObject.code);
    
    if (!
preloaded && infoObject.code == "NetStream.Play.Start") {
        
fInterval setInterval(checkFProgress,100);
    }
    } 
mpol777 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


All times are GMT. The time now is 12:30 AM.


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