26 Replies Latest reply: Feb 2, 2012 12:12 PM by kglad RSS

    FLV component stops playing video and reverses back to the play button

    nikolaig Community Member

      Hope there is a fix for it.

      So I have a video which plays in FLV component. It loads, it starts to play and then it stops on its own and a user has to click the play button again.

       

       

      Here is my code:

      //////////////////////////////////////////////////////////////////////////////////////////

      HowTo_maininfo_mc.JTVs_mc.JTV_SubHeart_btn.addEventListener(MouseEvent.CLICK, JTV_SubHeart_btn_amimated_btnDown);

       

      var sourceVar:String;

      function JTV_SubHeart_btn_amimated_btnDown(event:MouseEvent):void {

      sourceVar="howto_popups/jtvs18w07.mp4";

      gotoAndPlay("flv_pb");

      }

       

      //////////////////////////////////////////////////////////////////////////////////////////

       

      and then in "flv_pb" I have this:

      //////////////////////////////////////////////////////////////////////////////////////////

      stop();

       

       

       

      close_btn.addEventListener(MouseEvent.CLICK, onClick_GoBackToHowTo2);

       

       

      function onClick_GoBackToHowTo2(event:MouseEvent) :void {

                gotoAndPlay("howto");

       

      }

       

       

      SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

       

      function stopF2(e:Event):void{

      SWF_flv2.stop();

      }

       

       

      SWF_flv2.source=sourceVar;

        • 1. Re: FLV component stops playing video and reverses back to the play button
          kglad CommunityMVP

          does the same thing happen when testing locally?

          • 2. Re: FLV component stops playing video and reverses back to the play button
            nikolaig Community Member

            I checked thoroughly by tested locally and every single movie plays without any problems.

            I checked by opening the published side through Safari from the local HD and by choosing Control/Test Movie from Flash. In both cases everything works fine.

             

            Just in case here is my info on .mp4 file I am running via FLV playback component:

             

            Format:

            AAC, 2 channels, 48000 Hz

             

             

            FPS:

            29.97

             

             

            Data Size:

            130.3 MB

             

             

            Data Rate:

            1,200.19 kbit/s

             

             

            Current Size:

            874 x 480 pixels (Actual)

            • 3. Re: FLV component stops playing video and reverses back to the play button
              kglad CommunityMVP

              if your network download rate is less than 1,200.19 kbit/s you're going to see stuttering video play unless you preload that video.

              • 4. Re: FLV component stops playing video and reverses back to the play button
                nikolaig Community Member

                Stattering would be something I see when YouTube video takes time to download and play again. However it doesn't require a user to press a PLAY button again or it does?

                My assumption is that a user just waits until a video downloads and then plays again?

                 

                Or stattering is a tricky subject and in some cases it is expected that a user will have to activate a play button if video statters?

                 

                And second most important question:

                Is it possible/recommended to preload a video so user does not experience it? Or FLV component does not allow it?

                 

                 

                Third question: What is recommended kbit/s ratio for a movie to have?

                • 5. Re: FLV component stops playing video and reverses back to the play button
                  kglad CommunityMVP

                  repeatedly pressing the play button is not usually required.  there must be something specific in your set-up requiring that.

                   

                  yes, you can preload a video by starting it and immediately stopping it.  you can then use the progressevent to check your flv's download progress and start it playing when it's downloaded. 

                   

                  internet video should have a bitrate<384kbits/s.  256kbits/s is typical.

                   

                  p.s.  please mark helpful/correct responses, if there are any.

                  • 6. Re: FLV component stops playing video and reverses back to the play button
                    nikolaig Community Member

                    O.K. So I am way over the limit and have to bring the rate from 1,200.19 kbt/s down to 256 kbt/s

                     

                    I tried to do it in Adobe Media Converter but for some reason the program (AME) makes the video 640 x 480 instead of original 854 x 480. I guess it has something to do with the video size being divisible by 16.

                    It makes the video stretched noticeably in the vertical format. I can not reset it to the original proportions of 854 x 480. If I am adding the space from left and right or cropping it any differently it only adds black bars and still keeps the video compressed vertically.

                     

                    ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ -------------------------------------------------------

                     

                    You suggest that; "yes, you can preload a video by starting it and immediately stopping it.  you can then use the progressevent to check your flv's download progress and start it playing when it's downloaded. "

                     

                    Is the code for it too complicated?

                     

                    Please let me know if I should start a new discussion with this thread?

                    • 7. Re: FLV component stops playing video and reverses back to the play button
                      kglad CommunityMVP

                      to preload your video:

                       

                       

                      import fl.video.VideoProgressEvent;

                       

                      stop();

                      SWF_flv2.addEventListener(VideoProgressEvent.PROGRESS,progressF);

                       

                      SWF_flv2source = sourceVar;

                      SWF_flv2.play();

                      SWF_flv2.stop();

                       

                      function progressF(e:VideoProgressEvent):void{
                      if(e.bytesLoaded == e.bytesTotal){

                      trace(e.bytesLoaded,e.bytesTotal);

                      SWF_flv2.play();
                      }    
                      }

                      • 8. Re: FLV component stops playing video and reverses back to the play button
                        nikolaig Community Member

                        It started to work and then ( I guess my connection speed dropped) the progress bar started to appear and hang on the screen forever.

                        The audio starts and plays, however there is no video as video bar keeps on its loading progress. The video does not start at all.

                        • 9. Re: FLV component stops playing video and reverses back to the play button
                          kglad CommunityMVP

                          what's the url to this app and what needs to be done to see the problem, if it's not obvious?

                          • 10. Re: FLV component stops playing video and reverses back to the play button
                            nikolaig Community Member

                            I kept on testing and discovered that first issue keeps on happening. If not for the same coding reasons but it appears the same as an end result.

                            The video stops while it is being loaded and a user has to click the play button again in order so that the video will start to play.

                            For the test purposes I left the video on. It took about 50% of the video to load until it started automatically. It took about 3 min to come to that point

                             

                            If I can desipher correctly from the code it seems that the video will not resume playing unless it will be completely loaded : " if(e.bytesLoaded == e.bytesTotal){ "

                             

                            It takes very long time to load an entire video and a user will not wait for it. Therefore a user will be trying to press the play button, and then the video will stop again.

                             

                            If I am correct in my assumption of the bytesTotal - is there a way to specify that only a small portion of the video is required to be loaded in reference to the current time and then the video can start again? This should make a relatively quickly preloading process?

                             

                            Or there is some other way to go around it?

                            • 11. Re: FLV component stops playing video and reverses back to the play button
                              nikolaig Community Member

                              I appreciate you are looking to this extent into my problem.

                              The direct URL for this site is : http://www.888acolyte.com/acolyteVideosLG.html

                               

                              Please go to "how to" section and click through the videos.

                              Do not click on the first one as it points to the URL of another website. The rest of the videos use the code you have helped me with.

                               

                              I don't know if it matters, but just in case I set FLV component to the following values:

                              autoPlay=true,

                              and deleted everything from the source path, so it is empty

                              scaleMode=maintainAspectRatio

                              cuePoints=none

                              isLive=false

                              • 12. Re: FLV component stops playing video and reverses back to the play button
                                kglad CommunityMVP

                                the video is the only place on your site where i DON'T see a problem.  your swf performs like a non-optimized app on an iphone/ipad.  i can't remember ever seeing a web-based app perform that poorly.

                                 

                                but back to your video issue.  you're using a skin that shows the download progress of the mp4 and the play progress of the mp4.  do you see the download progress advancing ahead of play progress or does the play progress "catch" the download progress?

                                • 13. Re: FLV component stops playing video and reverses back to the play button
                                  nikolaig Community Member

                                  Yes, this is my first Flash website. I wish some one would tell me why it performs that poorly. I did it without prior education/mentoring. So it is done kind of in a dark on my own assumption of how it should be stractured. I watched a bunch of YouTube videos on how to stracture the site and then combined particular features from different learning resources...

                                  I guess that it is because there is a lot of animation and all of it done with Flash based time line tweening, so now I am trying to learn the GreenSock based tweening and am redoing entire website with AS3 based tweening rather than time line based.

                                  Looks that the site is bad enough for you to point it out more than in one sentence. Would you follow up with a more constructive criticism on a few major things that I did wrong? May I send you my working file to take a look at. Perhaps there will be a few big NO-NO's you will notice right away and it will better the site performance?

                                   

                                  Back to my best working feature: Videos

                                  Issue one (happens on some videos): For long time on the screen there will be download prgress. (the bar will have slanted green stripes running) Nothing would happen for a while....

                                  Issue two (happens on other videos): Video will start play immediately, relatively soon the play progress triangle will catch up with the progress bar. When it catches up the video stops playing and PAUSE reverts to PLAY (if PLAY would be pressed then the vide starts to play and soon stops again). For my testing purposes I left the website on (without pressing the PLAY) and it took almost 50% of the video to be loaded up and then it started to play again. Timewise it took around 3 min.

                                  • 14. Re: FLV component stops playing video and reverses back to the play button
                                    kglad CommunityMVP

                                    i strongly encourage your decision to use tweenlite instead of timeline tweening.  the benefits are signficant including but not limited to much better performance and tweens that are much easier to create, edit, tweak and maintain.  that's probably all you need to do to change the performance of that website from poor to excellent.

                                     

                                    your description of issues one and two are normal and expected.  when you see the green bars, flash is starting to download the mp4 and buffer the video.  when you see play progress catch download progress, you expect the video to stop.  if you wait until flash has buffered enough video (download progress advances ahead of play progress), the video should start by itself.  if you force it to continue play when not enough has buffered you should expect the video to stop as soon as play progress catches download progress.

                                     

                                    so, everything you've describe is expected.  to remedy either download the video before starting play (described above), get a better internet connection (i see no problem with your video playback becaues my connection is faster than your connection) and/or decrease the bitrate of your video.

                                    • 15. Re: FLV component stops playing video and reverses back to the play button
                                      nikolaig Community Member

                                      Thank you for all your detailed input. I appreciate you have spent considerable amount of time looking into it and your in-depth responces.

                                      At least I know I am on a right track....

                                      • 17. Re: FLV component stops playing video and reverses back to the play button
                                        nikolaig Community Member

                                        I randomly run into performance problems.

                                        I have 10 flv videos which set up through "var sourceVar:String;"

                                        After playing a few videos the player hangs on the downloading part of the next video.

                                        If I reload the site, then the same "troubled" video could be played again without any issues.

                                         

                                        Is it possible it is because of the "var sourceVar:String;" method? Would it create a better performance if each video would be playing in the separately segmented labeled section of the main time frame. This way there will be individual FLV player for each video and they would not "pile up" if this is why it happens?

                                        • 18. Re: FLV component stops playing video and reverses back to the play button
                                          kglad CommunityMVP

                                          no and no.

                                           

                                          are you having a problem a problem because more than 1 video is downloading at the same time?  if yes, use the closeVideoPlayer() method which will require you to juggle video player indices.

                                          • 19. Re: FLV component stops playing video and reverses back to the play button
                                            nikolaig Community Member

                                            There is nothing which specifies to load more than one video at a single time.

                                            Here is the code which I have in the label with the FLV component:

                                             

                                            stop();

                                             

                                             

                                             

                                            close_btn.addEventListener(MouseEvent.CLICK, onClick_GoBackToHowTo2);

                                             

                                             

                                            function onClick_GoBackToHowTo2(event:MouseEvent) :void {

                                                      gotoAndPlay("howto");

                                             

                                            }

                                             

                                             

                                            SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

                                             

                                            function stopF2(e:Event):void{

                                            SWF_flv2.stop();

                                            }

                                             

                                             

                                            SWF_flv2.source=sourceVar;

                                             

                                             

                                            Thoght that this line will stop the video froma residual loading:

                                            SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

                                             

                                             

                                            Could you please provide a code for closing the video player. Does it go on the labeled frame with FLV component or also on the section where the video buttons are located?

                                            Thnx

                                            • 20. Re: FLV component stops playing video and reverses back to the play button
                                              kglad CommunityMVP

                                              no, that doesn't stop the video from downloading.  it stops the video from playing.  it will continue to buffer unless you use the closeVideoPlayer() method.

                                               

                                              you should google how to use it because there are several steps that i don't recall that you need to take.  something like:

                                               

                                              SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

                                               

                                              function stopF2(e:Event):void{

                                              SWF_flv2.activeVideoPlayerIndex=1;

                                              SWF_flv2.closeVideoPlayerIndex(1);  // only execute this if the video has not completed download.  ie, use the progressevent

                                              SWF_flv2.stop();

                                              }

                                              • 21. Re: FLV component stops playing video and reverses back to the play button
                                                nikolaig Community Member

                                                O.K.

                                                I did not want to ask you again on that issue after you have already spent so much time on this.

                                                So after a diligent google search on "how to use closeVideoPlayer() method" for an hour and a half I mostly found people confessing how it is indeed the problem and how nothing really works. And calls to revert back to a reliable HTML.

                                                The only post with a positive thanks at the end of it was (surprise) yours from 2002.

                                                Here is a link to it: http://forums.adobe.com/thread/454999

                                                 

                                                Would it work in my case?

                                                • 22. Re: FLV component stops playing video and reverses back to the play button
                                                  kglad CommunityMVP

                                                  i've used closeVideoPlayerIndex() successfully before (to stop downloading unneeded streams).  so, it does work.

                                                   

                                                  and that other thread looks the same as the code i suggested above except i added a visibleVideoPlayIndex, too:

                                                   

                                                  ok, i just tested and it works.  but, you have to assign the player index before assigning the source:

                                                   

                                                   

                                                  SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

                                                   

                                                  function stopF2(e:Event):void{

                                                  SWF_flv2.stop();

                                                  SWF_flv2.closeVideoPlayerIndex(1);  // actually, you can execute this after the stream completes, too so there's no need to check.

                                                  }

                                                   

                                                  SWF_flv2.activeVideoPlayerIndex=1;

                                                  SWF_flv2.visibleVideoPlayerIndex=1;

                                                  SWF_flv2.source=sourceVar;

                                                  • 23. Re: FLV component stops playing video and reverses back to the play button
                                                    nikolaig Community Member

                                                    I am getting an error.

                                                    You mentioned that I have to assign the player index before assigning the source.

                                                    Just to make sure there is no extra steps to take to this task (as specifiying an index number in some FLV component special options/inspector). It is all reflected in your code provided:

                                                     

                                                    SWF_flv2.activeVideoPlayerIndex=1;  //this assigns the player index

                                                    SWF_flv2.visibleVideoPlayerIndex=1;  //this assigns the player index

                                                    SWF_flv2.source=sourceVar;              //source must come after assigning the index/s

                                                     

                                                    The line whic immediately preceds the code lines above is:

                                                    SWF_flv2.closeVideoPlayerIndex(1);

                                                     

                                                    and this is the one which gives me this error message:

                                                    1061: Call to a possibly undefined method closeVideoPlayerIndex through a reference with static type fl.video:FLVPlayback.

                                                    • 24. Re: FLV component stops playing video and reverses back to the play button
                                                      kglad CommunityMVP

                                                      my typo.  that should be:

                                                       

                                                      SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

                                                       

                                                      function stopF2(e:Event):void{

                                                      SWF_flv2.stop();

                                                      SWF_flv2.closeVideoPlayer(1);  // actually, you can execute this after the stream completes, too so there's no need to check.

                                                      }

                                                       

                                                      SWF_flv2.activeVideoPlayerIndex=1;

                                                      SWF_flv2.visibleVideoPlayerIndex=1;

                                                      SWF_flv2.source=sourceVar;

                                                      • 25. Re: FLV component stops playing video and reverses back to the play button
                                                        nikolaig Community Member

                                                        Looks like I finally got a working version of an FLV player.

                                                        Here is my final code:

                                                         

                                                         

                                                        import fl.video.VideoProgressEvent;

                                                         

                                                        stop();

                                                         

                                                         

                                                         

                                                        close_btn.addEventListener(MouseEvent.CLICK, onClick_GoBackToHowTo2);

                                                         

                                                        function onClick_GoBackToHowTo2(event:MouseEvent) :void {

                                                                  gotoAndPlay("howto");

                                                         

                                                        }

                                                         

                                                         

                                                         

                                                         

                                                        SWF_flv2.addEventListener(Event.REMOVED_FROM_STAGE,stopF2);

                                                         

                                                        function stopF2(e:Event):void{

                                                        SWF_flv2.stop();

                                                        SWF_flv2.closeVideoPlayer(1);  // actually, you can execute this after the stream completes, too so there's no need to check.

                                                        }

                                                         

                                                         

                                                         

                                                        SWF_flv2.addEventListener(VideoProgressEvent.PROGRESS,progressF);

                                                         

                                                        function progressF(e:VideoProgressEvent):void{

                                                        if(e.bytesLoaded == e.bytesTotal){

                                                        trace(e.bytesLoaded,e.bytesTotal);

                                                        SWF_flv2.play();

                                                        }    

                                                        }

                                                         

                                                         

                                                         

                                                        SWF_flv2.activeVideoPlayerIndex=1;  //this assigns the player index

                                                        SWF_flv2.visibleVideoPlayerIndex=1; //this assigns the player index

                                                         

                                                         

                                                         

                                                        SWF_flv2.source = sourceVar;  //source must come after assigning the index/s

                                                        //SWF_flv2.play();

                                                        //SWF_flv2.stop();

                                                         

                                                         

                                                        I blocked out two last SWF_flv2.play(); and SWF_flv2.stop(); as they seem to be residual pieces of code from the first code solution of the Helpful Answer.

                                                        Or they should appear twice?

                                                        • 26. Re: FLV component stops playing video and reverses back to the play button
                                                          kglad CommunityMVP

                                                          the play()/stop() code is used to start buffering your sourceVar.  if you don't want/need to buffer, don't.