13 Replies Latest reply on Feb 12, 2010 7:20 AM by kglad

    adding time to the FLVplayback component

    danielnr87

      Hi everyone, Im using the FLVplayback component for a project im doing. I want to add the time elapsed and time left on the controls. I dont really want to create my own controls, as im happy with the flv playback component. The FLVs playing in the component are external and are loaded into it via as3

       

      Is there a quick and easy way of doing this?

       

      Cheers
      Dan

        • 1. Re: adding time to the FLVplayback component
          kglad Adobe Community Professional & MVP

          sure, just overlay textfield(s) in the position(s) you want.

          • 2. Re: adding time to the FLVplayback component
            waterdad568 Level 3

            I'm not aware of a native UI component skin for the FLVPlayback component that has a numerical progress indicator, there are however many with seekbar progress indicators... so...  you will have to build one.

            • 3. Re: adding time to the FLVplayback component
              danielnr87 Level 1

              I know how to overlay the dynamic text fields, i was just stuck thinking about the code i need.

               

              Where does the time information get pulled from? and do i do this on the flv component itsself, or in my flash project?

               

              any help appreciated!

               

              cheers

              • 4. Re: adding time to the FLVplayback component
                danielnr87 Level 1

                I have managed to find some code for this component, but im getting some errors which im having trouble to de-bug;

                 

                1118: Implicit coercion of a value with static type Object to a possibly unrelated type Function. vidPlayer.addEventListener("metadataReceived", listenerObject);

                 

                1118: Implicit coercion of a value with static type Object to a possibly unrelated type Function. vidPlayer.addEventListener("playheadUpdate", listenerObject);

                 

                Please would someone take a look and let me know what im doing wrong?

                 

                Thanks

                 

                 

                 

                 

                 

                code:

                var listenerObject:Object = new Object();
                var fullDuration = null;
                listenerObject.metadataReceived = function(eventObject:Object):void {
                    fullDuration = prettyTime(vidPlayer.metadata.duration);
                };
                listenerObject.playheadUpdate = function(eventObject:Object):void {
                    var paTime = vidPlayer.playheadTime;
                    if(fullDuration != null){
                //updates the text box with the instance name timeCode_txt on the root timeline.
                //best to use a monospace typeface like calibri for the textbox font.
                        time_txt.text = prettyTime(vidPlayer.playheadTime) + " / " + fullDuration;
                    }
                };

                vidPlayer.addEventListener("metadataReceived", listenerObject);
                vidPlayer.addEventListener("playheadUpdate", listenerObject);

                function prettyTime(timeinSeconds):String{
                    var seconds:Number = Math.floor(timeinSeconds);
                    var minutes:Number = Math.floor(seconds / 60);
                    var hours:Number = Math.floor(minutes / 60);

                    //Storing the remainder of this division problem
                    seconds %= 60;
                    minutes %= 60;
                    hours %= 24;

                    //Converting numerical values into strings so that
                    //we string all of these numbers together for the display
                    var sec:String = seconds.toString();
                    var min:String = minutes.toString();
                    var hrs:String = hours.toString();

                    //Setting up a few restrictions for when the current time reaches a single digit
                    if (sec.length < 2) {
                        sec = "0" + sec;
                    }

                    if (min.length < 2) {
                        min = "0" + min;
                    }

                    if (hrs.length < 2) {
                        hrs = "0" + hrs;
                    }

                    //Stringing all of the numbers together for the display
                    var time:String = hrs + ":" + min + ":" + sec;
                    //Setting the string to the display
                    return time;
                }

                • 5. Re: adding time to the FLVplayback component
                  kglad Adobe Community Professional & MVP

                  you're publishing for as3 and you're using as2 code.

                  1 person found this helpful
                  • 6. Re: adding time to the FLVplayback component
                    danielnr87 Level 1

                    ahh. thunk.

                     

                    i knew it looked a little funny.

                     

                    How can I create the same thing but in as3?

                    there must be a simple method?

                     

                    cheers

                    • 7. Re: adding time to the FLVplayback component
                      kglad Adobe Community Professional & MVP

                      use:

                       

                      import fl.video.VideoEvent;
                      import fl.video.MetadataEvent;

                      var fullDuration:String = "";
                      function metadataReceivedF(e:MetadataEvent):void {
                          fullDuration = prettyTime(vidPlayer.metadata.duration);
                      };
                      function updateF(e:VideoEvent):void {
                          var paTime = vidPlayer.playheadTime;
                          if(fullDuration != ""){
                              time_txt.text = prettyTime(vidPlayer.playheadTime) + " / " + fullDuration;
                          }
                      };

                      vidPlayer.addEventListener(MetadataEvent.METADATA_RECEIVED, metadataReceivedF);
                      vidPlayer.addEventListener(VideoEvent.PLAYHEAD_UPDATE, updateF);

                      function prettyTime(timeinSeconds:Number):String{
                          var seconds:Number = Math.floor(timeinSeconds);
                          var minutes:Number = Math.floor(seconds/60);
                          var hours:Number = Math.floor(minutes/60);
                         
                          seconds %= 60;
                          minutes %= 60;
                         
                          var sec:String = seconds.toString();
                          var min:String = minutes.toString();
                          var hrs:String = hours.toString();

                          while(sec.length < 2) {
                              sec = "0" + sec;
                          }
                          while(min.length < 2) {
                              min = "0" + min;
                          }
                          while(hrs.length < 2) {
                              hrs = "0" + hrs;
                          }
                         return hrs + ":" + min + ":" + sec;
                      }

                      • 8. Re: adding time to the FLVplayback component
                        danielnr87 Level 1

                        kglad your a life saver

                         

                        double chuffed

                         

                        cheers mate

                        • 9. Re: adding time to the FLVplayback component
                          kglad Adobe Community Professional & MVP

                          you're welcome.

                           

                          if you're still able, please mark this thread as answered.

                          • 10. Re: adding time to the FLVplayback component
                            danielnr87 Level 1

                            Will do,

                             

                            just another qustion...if im not asking too much!? How can i now integrate this into the flvplayback bar itself? I forgot that it doesnt appear under full screen mode!

                             

                            Cheers for the help.

                             

                            Will leave it as answered tommorw morning when im back at work tommorow

                             

                            Cheers

                            Dan

                            • 11. Re: adding time to the FLVplayback component
                              kglad Adobe Community Professional & MVP

                              you can't easily do that.

                              • 12. Re: adding time to the FLVplayback component
                                danielnr87 Level 1

                                ok thanks.

                                 

                                also, I would like to get this working in as2 aswel. (i have some old pages i would like to add it to.)

                                 

                                The original as2 i posted throws up a load of errors.

                                 

                                Can you see anything in the code thats wrong?

                                 

                                Cheers mate

                                Dan

                                • 13. Re: adding time to the FLVplayback component
                                  kglad Adobe Community Professional & MVP

                                  that's as3 code and won't work in as2.  you'll need to convert.

                                  1 person found this helpful