9 Replies Latest reply on Feb 3, 2012 9:27 AM by adninjastrator

    How to make an FLV component to play videos automatically

    nikolaig Level 1

      After much discussions and great help I finally got the working FLV component.

      Here is my entire code from the label with an FLV component.

       

      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.

      }

       

       

                play_btn.addEventListener(MouseEvent.CLICK, onClick_Play);

       

            function onClick_Play(event:MouseEvent) :void {

                          SWF_flv2.play();

                          }    

       

       

      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();

       

       

       

      Somehow the video doesn't play automatically eventhough the "autoPlay=true" in the components inspector oprtions.

       

       

      I would like to find out if there is any specific line of code which should make the video play automatically in addition to:

       

      SWF_flv2.addEventListener(VideoProgressEvent.PROGRESS,progressF);

       

      function progressF(e:VideoProgressEvent):void{

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

      trace(e.bytesLoaded,e.bytesTotal);

      SWF_flv2.play();

      }    

      }

       

      Is there something in the code I messed up and this set up does not function properly?

       

      I also wanted to make play button. Kind of this huge one in the middle of the screen as users used to see on YouTube.

      Here is the code for it which seems to work:

      play_btn.addEventListener(MouseEvent.CLICK, onClick_Play);

       

            function onClick_Play(event:MouseEvent) :void {

        SWF_flv2.play();

        }    

       

      The problem is it doesn't dissapear once the video plays. How shoudl it be done, the whole video has to go to another frame with no play_btn on it or there is a code which can make it fade away?

        • 1. Re: How to make an FLV component to play videos automatically
          kglad Adobe Community Professional & MVP

          assign your flv pb's autoPlay to true and don't assign the play()/stop().

          • 2. Re: How to make an FLV component to play videos automatically
            nikolaig Level 1

            But then will it buffer or it will just stop and user will have keep on pressing the PLAY button again and again.

             

            The problem is that with the slow connection speeds the video starts to stop and then a user starts to press the play button again and again....

            Perhpas loading bar allows user to see that something is happening and so he/she patiently waits rather than starts click all the time.

            What would be the best user experience in your opinion?

            • 3. Re: How to make an FLV component to play videos automatically
              kglad Adobe Community Professional & MVP

              it will buffer with autoPlay enabled but you may see stops and starts with slow connections.  you can disable the controls so a user can't try and advance while the video is buffereing by enabling the bufferingBarHidesAndEnablesOthers property.

               

              or disable autoPlay, use the play()/stop() and use the videoprogressevent.progress to determine when to start your video.

              1 person found this helpful
              • 4. Re: How to make an FLV component to play videos automatically
                nikolaig Level 1

                Thank you for your continuous support.

                Are there any other expected pitfalls or everything seems to be in order?

                Or there is no such thing as every FLV set up is unique and problems have to be solved accordingly...

                • 5. Re: How to make an FLV component to play videos automatically
                  kglad Adobe Community Professional & MVP

                  not every flv setup is unique but each persons concerns and wants determine what they should do and there are general guidelines.  is the most important thing smooth playback?  is it high quality video?  is it a large video size?  is it a video that starts promptly?

                   

                  for example, when i create apps with videos i tell clients to send me flv's with bitrates that will meet their needs.  and they can't have everything:  for example, a video with low bitrate (so the flv plays smoothly for users with narrow bandwidth) and high quality (so it looks sharp) with a large video size are incompatible.  they must pick and choose and possibly compromise. 

                   

                  in general, the lower the bitrate the more satisfactory playback is for more people and the lower the video quality and/or the smaller the video size.  but if you want high quality and a larger video size but don't want stop/start playback, you must buffer enough video (and thereby delay the video's start) so during playback the playing part of the video doesn't catch up to the buffered part.

                  1 person found this helpful
                  • 6. Re: How to make an FLV component to play videos automatically
                    adninjastrator Level 4

                    I see that you are asking a number of questions about Flash video. With that in mind, I'd like to remind you that using the FLVPlayback component is not the ONLY Flash option. You could use "NetStream" and have a much more powerful and versatile option of dealing and interacting with Flash:

                    For just one of many references:

                    http://injun.ru/flash10api/flash/net/NetStream.html

                    While it may take a little more learning at the start, the end result will be a video player where you create your own customs skins, controls, start/stop options, easy interactions with other Flash apps/or sections of the main timeline/cuepoints... and the list goes on.

                    I have posted hundreds and hundreds of Web videos and have NEVER used the FLVPlayback component. I must admit that my only experience with the FLVPlayback component comes from trouble-shooting video related questions from others posted here in the Adobe Forum.

                    I just wanted to make you aware of that option. Here is a great starter tutorial to get you going using your own NetStream Flash video player:

                    http://www.gotoandlearn.com/

                    Scroll to the very bottom of the page.

                    Here is an example of one of my NetStream video player displaying a .flv video with alpha channel encoded (transparent background) which then interacts with another video which plays in the background:

                    http://mrfilmbiz.com/

                    Here is an example of another of my NetStream players with an .xml playlist that also includes a custom skin, playlist, categories, and video narrations linked to the video via xml:

                    http://www.drheimer.com/video/

                    If you are looking for a quick embed video... just use a YouTube or even a FLVPlayback... but if you want more, consider NetStream.

                    Best wishes,

                    Adninjastrator

                    1 person found this helpful
                    • 7. Re: How to make an FLV component to play videos automatically
                      adninjastrator Level 4

                      kglad brings up a very good point... understanding video bitrate is vital to producing quality Internet video. For your review... a little dated but still good for a basic understanding:

                      Video bit rate

                       

                      One of the principle of goal setting is to "Begin with the end in mind". In this case it'll be very hard to give good recommendations because the end is not defined. So I'll just make a few assumptions and you can correct me as needed.
                      First, I'll assume that since you are converting to Flash, you want to deliver this video over the Internet. If that's true, then we'll have to make some assumptions on the Internet connection download speeds of your potential viewers. Let's just say that most have at least a 1.5Mb connection or faster.
                      OK, that would mean that a video bitrate of half that should usually provide a video download that is not interupped by buffering (most of the time anyway). So assuming a video bitrate of 750kbps, what would the optimum display dimensions be?
                      Before we decide, here's a little info about bitrate. For highest quality playback, the video bitrate is tied directly to the display dimensions. That is, the larger the display, the more incoming data is required to properly display the video. Think of bitrate in terms of a can of paint. If you have 1 quart of paint, you might be able to do a very nice job on a 32 X 24 foot area. But if you try to stretch that same amount of paint out over a 64 X 48 foot area, the coverage will not be nearly as good and you get poor results.
                      In the same way, a video displayed at 640 X 480 pixels will require 4 times the bitrate as a video displayed at 320 X 240 pixels to produce the same quality. So for example a video with a bitrate of 100kbps, displayed at 160 X 120 will produce the same quality results as a video with a bitrate of 1600kbps if displayed at 640 X 480.
                      So to boil it all down, video bitrates of 750kbps, even up to 1000kbps can usually get delivered of the Internet on most high speed connections. Higher bit rates may work for really fast connections but will cause problems for viewers with slower connections. Video display size has a direct bearing on the final quality. In the 750 to 1000kbps range, display size should be kept around 450 or 500 width max (and whatever height the aspect ratio calls for). Yes it can be displayed larger, but the quality will suffer.
                      Sound like your audio settings are fine, especially for Internet delivery.
                      As for framerate, maintain the original raw video framerate for best results. So if the video was shot at 24fps, leave it.
                      As for video converters, do you have the Flash 8 Video Converter? It works just fine for video to be delivered over the Internet. Remember, you are taking a Cadillac version of video (h.264 HD) and stuffing it into a Chevy body to get it to work over the Internet.

                      Adninjastrator

                      1 person found this helpful
                      • 8. Re: How to make an FLV component to play videos automatically
                        nikolaig Level 1

                        Appreciate your feedback, Looking forward the weekends to start going through the tutorials and emerge with a better video player.

                        What is your opinion on the "AS3 Video Loading with GreenSock LoaderMax".

                        I started to work with it but it seemed to much of the coding for my level. It will require a more serious time involvement on my part to make it work.

                        Here is a link to it:

                        http://active.tutsplus.com/tutorials/actionscript/smart-as3-video-loading-with-greensock-l oadermax-free-active-premium/

                        • 9. Re: How to make an FLV component to play videos automatically
                          adninjastrator Level 4

                          I have seen several working examples of this loader and would suggest you at least keep that option open. I personally have not used it but I have recommended other look into the feature and operation.

                          As you work you way through NetStream you'll start to understand more about starting the loading process, then stop, or pausing that while you load a few frames from a second/third etc. video.

                          Best wishes,

                          Adninjastrator