Bug 669616 - Round time to the nearest full-second value to fix inaccuracies in audio controls. r=dolske
authorPaul ADENOT <paul@paul.cx>
Mon, 11 Jul 2011 12:24:20 -0700
changeset 72628 67397e750a3a4370a3c0d7a7745bc5bd83532e16
parent 72627 f2390732b6a4ab55a7030e58c5a85d8e8893bc65
child 72629 aaeabf9d44d487162d9b42e940953fbf5bec3c6c
push idunknown
push userunknown
push dateunknown
reviewersdolske
bugs669616
milestone8.0a1
Bug 669616 - Round time to the nearest full-second value to fix inaccuracies in audio controls. r=dolske
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -51,19 +51,20 @@
         </setter>
       </property>
 
       <method name="setTime">
           <parameter name="time"/>
           <body>
           <![CDATA[
               var timeString;
-              var hours = Math.floor(time / 3600000);
-              var mins  = Math.floor(time % 3600000 / 60000);
-              var secs  = Math.floor(time % 60000 / 1000);
+              time = Math.round(time / 1000);
+              var hours = Math.floor(time / 3600);
+              var mins  = Math.floor((time % 3600) / 60);
+              var secs  = Math.floor(time % 60);
               if (secs < 10)
                   secs = "0" + secs;
               if (hours || this.showHours) {
                   if (mins < 10)
                       mins = "0" + mins;
                   timeString = hours + ":" + mins + ":" + secs;
               } else {
                   timeString = mins + ":" + secs;
@@ -539,19 +540,20 @@
                 terminateEventListeners : function () {
                     for each (var event in this.videoEvents)
                         this.video.removeEventListener(event, this, false);
                     this.log("--- videocontrols terminated ---");
                 },
                 
                 formatTime : function(aTime) {
                     // Format the duration as "h:mm:ss" or "m:ss"
-                    let hours = Math.floor(aTime / 3600000);
-                    let mins  = Math.floor(aTime % 3600000 / 60000);
-                    let secs  = Math.floor(aTime % 60000 / 1000);
+                    aTime = Math.round(aTime / 1000);
+                    let hours = Math.floor(aTime / 3600);
+                    let mins  = Math.floor((aTime % 3600) / 60);
+                    let secs  = Math.floor(aTime % 60);
                     let timeString;
                     if (secs < 10)
                         secs = "0" + secs;
                     if (hours) {
                         if (mins < 10)
                             mins = "0" + mins;
                         timeString = hours + ":" + mins + ":" + secs;
                     } else {