1 Reply Latest reply on Jul 8, 2010 9:46 PM by Vincent-ZHANG

    Problem with video playback function, can not detect the end

    Vincent-ZHANG

      I am working on a Flash project, it has a module, that will play some video and display image as advertisements, and I set a listener that will trace when the video is playing, if the playing ends, and listener will do something...

       

      videoListener.onEnterFrame = function() {
         
          // no need to listen, it is image now
          if (listening == false) {
              return;
          }
             
          // listen if the video is finished   
          if (mc_holder_master.mc_holder.video_mc.videoEnd == true) {
              // copy master mc's content to shadow mc, and load the new media content
              ID++;

       

              duplicateImage(mc_holder_master, mc_holder_slave);
              mc_holder_slave._visible = true;
            

                listening = false;
             
              unloadMovie(mc_holder_master.mc_holder);
              if(type[ID] == 2)
              {
                  // it is video
                  _global.toLoad = media[ID];       
                  _global.Width = widths[ID];
                  _global.Height = heights[ID];
                 
                  mc_holder_master.mc_holder.loadMovie(player);
              }
              else if(type[ID] == 1)
              {
                  // it is image
                  mc_holder_master.mc_holder.loadMovie(media[ID]);
                 
              }

       

          }
      };

       

       

      Indeed, mc_holder_master is a holder mc, it loads an external swf: videoPlayer.swf, and in videoPlayer.swf, there is a piece of code on the player mc's timeline, as following:

       

      onEnterFrame = function () {
              percentage = Math.round((ns.bytesLoaded / ns.bytesTotal) * 100);
              controls_mc.progress_mc.buffer_mc._xscale = percentage;
              ns_seconds = ns.time;
              minutes = Math.floor(ns_seconds / 60);
              seconds = Math.floor(ns_seconds % 60);
              if (seconds < 10) {
                  seconds = "0" + seconds;
              }
              controls_mc.sound_time_mc.time_txt.text = (((minutes + ":") + seconds) + " / ") + durationDisplay;
              if ((ns.time >= duration) && (duration != undefined)) {
                  controls_mc.progress_mc.played_mc._xscale = 100;
                  if (videoEnd == false) {
                      controls_mc.bttnPlay.icon_mc.gotoAndStop(2);
                      videoEnd = true;
                  }
              } else {
                  controls_mc.progress_mc.played_mc._xscale = Math.round((ns.time * 100) / duration);
                  videoEnd = false;
              }
          };

       

      videoEnd  is just a variable to record the status of video's playing, it is determined by comparing the video's total duration and the current time.

       

      On the other hand, desides this advertising module, the main Flash program has another module as well, that will display some static images, just like slide, and it will cover the whole area of the Flash program.

       

      And now go to the problem:

       

      If the image-sliding module show up, one specific video will get stuck at its end, I mean, the playing is already finished, but the listener doesn't detect that, and it will not do what it should do. this piece of code is not executed:

       

               
              ID++;


              duplicateImage(mc_holder_master, mc_holder_slave);
               mc_holder_slave._visible = true;
             

                listening = false;
              
               unloadMovie(mc_holder_master.mc_holder);
               if(type[ID] == 2)
               {
                   // it is video
                   _global.toLoad = media[ID];       
                   _global.Width = widths[ID];
                   _global.Height = heights[ID];
                  
                   mc_holder_master.mc_holder.loadMovie(player);
               }
               else if(type[ID] == 1)
               {
                   // it is image
                   mc_holder_master.mc_holder.loadMovie(media[ID]);
                  
               }

       

       

      And the wierd part of this problem is that the very video that got stuck is a video record by myself with my DC, and I converted it to flv with Riva. All the other videos do not encounter the problem, some of them are flvs I downloaded from Web, some are converted from other avi format videos.

       

      Okay, let me conclude:

       

      if the image-sliding never shows up, everything is just fine.

      if the image-sliding shows-up, the advertisement module will get stuck at the video's end, and that will only happen to my own video.

      if the advertisement module get stuck at my video's end, then I can click the progress bar to get the video play again(no need to replay the whole, just a few seconds is ok), and then the advertisement module will continue to work correctly again.......