Preloader working, audio starts on video but preloader still shows

It's been long and long since I worked with Flash, and this one has me stumped.  This seems to be worse when it's on my server, but it's still reproducible locally.  I have a Flash file that loads external .swfs (all videos) into a Loader component.  I have a preloader that uses getBytesLoaded() and getBytesTotal() to both update itself and to determine when the movie gets to play.  So far, so good.  Unfortunately, it might be showing only 5 or 10% loaded, but the audio starts on the video!  Still can't see the video itself until the preloader hits 100%.  I've tried changing the threshold for when the movie should start playing, but it doesn't make a difference: audio still starts way before the preloader is complete, and it doesn't want to hide early either.

I tried using the ProgressBar component with the same results.

Any idea what I can do to keep the movie clip loaded into the Loader from starting until I say so?
LVL 9
valkyrie_ncAsked:
Who is Participating?
 
rythmik1Connect With a Mentor Commented:
This is a function I use to calculate an FLV's load percent.. it uses bufferLength and bufferTime. Not sure if that will help you. I load my flvs into a video object and control them without components. It's alot lighter and easier to work with than dealing with swfs once you get the hang of it.

videoProgress.onEnterFrame = function() {
            nsBufLen = stream_stream.bufferLength;
            bLoaded = Math.floor(stream_stream.time);
            vidPercentLoaded = 100*(Math.floor(nsBufLen)/stream_stream.bufferTime);
            videoProgress.loadText.text = "LOADING: "+vidPercentLoaded+"%";
            if ((vidPercentLoaded<99)) {
                  videoProgress.progressBar._xscale = vidPercentLoaded;
                  videoProgress.progressBar._alpha = 100;
                              
            } else {
                  videoProgress.progressBar._xscale = 100;
                  delete(videoProgress.onEnterFrame);
                  videoProgress.onEnterFrame=function() {
                        videoProgress._alpha=videoProgress._alpha-5;
                        if(videoProgress._alpha<1) {
                              delete(videoProgress.onEnterFrame);
                        }
                  }
                  
            }
      };
0
 
rythmik1Commented:
Are you loading the videos as videos converted into SWFs or as FLVs?
0
 
valkyrie_ncAuthor Commented:
They're FLVs embedded into .swfs, so the file being loaded is a .swf
0
 
rythmik1Commented:
note: here's the first part of the code that would actually load the flv and set the volume etc:

      var connection_connection;
      var stream_stream;
      my_video._alpha = 100;
      playVideo = function () {
            connection_connection = new NetConnection();
            connection_connection.connect(null);
            stream_stream = new NetStream(connection_connection);
            stream_stream.setBufferTime(5);
            my_video.attachVideo(stream_stream);
            
            this.createEmptyMovieClip("movFLVAudio", this.getNextHighestDepth());
            movFLVAudio.attachAudio(stream_stream);
            var snd1:Sound = new Sound(movFLVAudio);
            snd1.setVolume(50);
            
            stream_stream.onMetaData = function(obj) {
                  _global.bufTime = obj.duration;
                  totalPlayTime = obj.duration;
                  trace(_global.bufTime);
            };

                  
                  stream_stream.play("YOURFLV.flv");
      };
      playVideo();
0
 
valkyrie_ncAuthor Commented:
Thanx, rythmik1 :)  I'll give it a try & see if it behaves itself better.  Appreciate the info. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.