Bug 619752 part 2 - Fix the front end to display infinite media duration. r=dolske
authorPaul ADENOT <paul@paul.cx>
Mon, 01 Aug 2011 14:11:28 -0400
changeset 73630 37e5ad24bc64a6908bf0ca9f1dabc219eb4280fd
parent 73629 993507024dc6548dbffa2b9ef85fc69651c49888
child 73631 445abd683ea40969351d33bb070d2894a7872506
push id20900
push usermak77@bonardo.net
push dateTue, 02 Aug 2011 09:54:14 +0000
treeherdermozilla-central@10927265c555 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs619752
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 619752 part 2 - Fix the front end to display infinite media duration. r=dolske
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -303,17 +303,16 @@
                                "loadstart", "timeupdate", "progress",
                                "playing", "waiting", "canplay", "canplaythrough",
                                "seeking", "seeked", "emptied", "loadedmetadata",
                                "error", "suspend", "stalled"],
 
                 firstFrameShown : false,
                 timeUpdateCount : 0,
                 maxCurrentTimeSeen : 0,
-                lastDurationSeen : NaN,
                 isAudioOnly : false,
 
                 setupStatusFader : function(immediate) {
                     var show = false;
                     if (this.video.seeking ||
                         this.video.error ||
                         this.video.networkState == this.video.NETWORK_NO_SOURCE ||
                         (this.video.networkState == this.video.NETWORK_LOADING &&
@@ -543,17 +542,17 @@
                     }
                 },
 
                 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"
                     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)
@@ -564,25 +563,24 @@
                         timeString = hours + ":" + mins + ":" + secs;
                     } else {
                         timeString = mins + ":" + secs;
                     }
                     return timeString;
                 },
 
                 showDuration : function (duration) {
-                    if (isNaN(duration))
+                    let isInfinite = (duration == Infinity);
+                    this.log("Duration is " + duration + "ms.\n");
+
+                    if (isNaN(duration) || isInfinite)
                         duration = this.maxCurrentTimeSeen;
-                    if (duration == this.lastDurationSeen)
-                        return;
-                    this.lastDurationSeen = duration;
-                    this.log("Duration is " + duration + "ms");
 
                     // Format the duration as "h:mm:ss" or "m:ss"
-                    let timeString = this.formatTime(duration);
+                    let timeString = isInfinite ? "" : this.formatTime(duration);
                     this.durationLabel.setAttribute("value", timeString);
 
                     // "durationValue" property is used by scale binding to
                     // generate accessible name.
                     this.scrubber.durationValue = timeString;
 
                     // If the duration is over an hour, thumb should show h:mm:ss instead of mm:ss
                     this.scrubberThumb.showHours = (duration >= 3600000);
@@ -608,18 +606,16 @@
                 },
 
                 showPosition : function(currentTime, duration) {
                     // If the duration is unknown (because the server didn't provide
                     // it, or the video is a stream), then we want to fudge the duration
                     // by using the maximum playback position that's been seen.
                     if (currentTime > this.maxCurrentTimeSeen)
                         this.maxCurrentTimeSeen = currentTime;
-                    if (isNaN(duration))
-                      duration = this.maxCurrentTimeSeen;
                     this.showDuration(duration);
 
                     this.log("time update @ " + currentTime + "ms of " + duration + "ms");
 
                     this.positionLabel.setAttribute("value", this.formatTime(currentTime));
                     this.scrubber.value = currentTime;
                 },