Bug 876380. Update 'show clickToPlay button' state after each load. r=dolske,a=jonas
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 29 May 2013 02:35:35 +1200
changeset 119037 dabb3cc21eb95fb0c626ca459aed53f9a64653ad
parent 119036 6a665aaf977b01f9c424c030dc40740aef6fd5d6
child 119038 9ff01472b61b9746398a5878a69ae9dc0e1562ef
push id204
push userrocallahan@mozilla.com
push dateTue, 28 May 2013 14:42:54 +0000
reviewersdolske, jonas
bugs876380
milestone18.0
Bug 876380. Update 'show clickToPlay button' state after each load. r=dolske,a=jonas
toolkit/content/widgets/videocontrols.xml
--- a/toolkit/content/widgets/videocontrols.xml
+++ b/toolkit/content/widgets/videocontrols.xml
@@ -352,18 +352,20 @@
                 timeUpdateCount : 0,
                 maxCurrentTimeSeen : 0,
                 isAudioOnly : false,
 
                 setupStatusFader : function(immediate) {
                     // Since the play button will be showing, we don't want to
                     // show the throbber behind it. The throbber here will
                     // only show if needed after the play button has been pressed.
-                    if (!this.clickToPlay.hidden)
+                    if (!this.clickToPlay.hidden) {
+                        this.startFadeOut(this.statusOverlay, true);
                         return;
+                    }
 
                     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 &&
                          (this.video.paused || this.video.ended
                            ? this.video.readyState < this.video.HAVE_CURRENT_DATA
@@ -467,16 +469,36 @@
                     // Preserve Statistics when toggling fullscreen mode due to bug 714071.
                     if (this.video.mozMediaStatisticsShowing)
                         this.showStatistics(true);
 
                     this._handleCustomEventsBound = this.handleCustomEvents.bind(this);
                     this.video.addEventListener("media-showStatistics", this._handleCustomEventsBound, false, true);
                 },
 
+                setupNewLoadState : function() {
+                    // videocontrols.css hides the control bar by default, because if script
+                    // is disabled our binding's script is disabled too (bug 449358). Thus,
+                    // the controls are broken and we don't want them shown. But if script is
+                    // enabled, the code here will run and can explicitly unhide the controls.
+                    //
+                    // For videos with |autoplay| set, we'll leave the controls initially hidden,
+                    // so that they don't get in the way of the playing video. Otherwise we'll
+                    // go ahead and reveal the controls now, so they're an obvious user cue.
+                    //
+                    // (Note: the |controls| attribute is already handled via layout/style/html.css)
+                    var shouldShow = this.video.paused &&
+                       (!(this.video.autoplay && this.video.mozAutoplayEnabled) ||
+                        !this.dynamicControls);
+                    // Hide the overlay if the video time is non-zero or if an error occurred to workaround bug 718107.
+                    this.startFade(this.clickToPlay, shouldShow && !this.isAudioOnly &&
+                                   this.video.currentTime == 0 && !this.hasError(), true);
+                    this.startFade(this.controlBar, shouldShow, true);
+                },
+
                 handleCustomEvents : function (e) {
                     if (!e.isTrusted)
                         return;
                     this.showStatistics(e.detail);
                 },
 
                 get dynamicControls() {
                     // Don't fade controls for <audio> elements.
@@ -557,16 +579,18 @@
                             break;
                         case "loadstart":
                             this.maxCurrentTimeSeen = 0;
                             this.controlsSpacer.removeAttribute("aria-label");
                             this.statusOverlay.removeAttribute("error");
                             this.statusIcon.setAttribute("type", "throbber");
                             this.isAudioOnly = (this.video instanceof HTMLAudioElement);
                             this.setPlayButtonState(true);
+                            this.setupNewLoadState();
+                            this.setupStatusFader();
                             break;
                         case "progress":
                             this.statusIcon.removeAttribute("stalled");
                             this.showBuffered();
                             this.setupStatusFader();
                             break;
                         case "stalled":
                             this.statusIcon.setAttribute("stalled", "true");
@@ -600,16 +624,17 @@
                             // responses (don't yank the thumb away from the user)
                             if (this.scrubber.isDragging)
                                 return;
 
                             this.showPosition(currentTime, duration);
                             break;
                         case "emptied":
                             this.bufferBar.value = 0;
+                            this.showPosition(0, 0);
                             break;
                         case "seeking":
                             this.showBuffered();
                             this.statusIcon.setAttribute("type", "throbber");
                             this.setupStatusFader();
                             break;
                         case "waiting":
                             this.statusIcon.setAttribute("type", "throbber");
@@ -1375,32 +1400,17 @@
                     this.stats.readyState = document.getAnonymousElementByAttribute(binding, "class", "statReadyState");
                     this.stats.netState   = document.getAnonymousElementByAttribute(binding, "class", "statNetState");
                     this.stats.framesParsed    = document.getAnonymousElementByAttribute(binding, "class", "statFramesParsed");
                     this.stats.framesDecoded   = document.getAnonymousElementByAttribute(binding, "class", "statFramesDecoded");
                     this.stats.framesPresented = document.getAnonymousElementByAttribute(binding, "class", "statFramesPresented");
                     this.stats.framesPainted   = document.getAnonymousElementByAttribute(binding, "class", "statFramesPainted");
 
                     this.setupInitialState();
-
-                    // videocontrols.css hides the control bar by default, because if script
-                    // is disabled our binding's script is disabled too (bug 449358). Thus,
-                    // the controls are broken and we don't want them shown. But if script is
-                    // enabled, the code here will run and can explicitly unhide the controls.
-                    //
-                    // For videos with |autoplay| set, we'll leave the controls initially hidden,
-                    // so that they don't get in the way of the playing video. Otherwise we'll
-                    // go ahead and reveal the controls now, so they're an obvious user cue.
-                    //
-                    // (Note: the |controls| attribute is already handled via layout/style/html.css)
-                    var shouldShow = (!(this.video.autoplay && this.video.mozAutoplayEnabled) || !this.dynamicControls);
-                    // Hide the overlay if the video time is non-zero or if an error occurred to workaround bug 718107.
-                    this.startFade(this.clickToPlay, shouldShow && !this.isAudioOnly &&
-                                   this.video.currentTime == 0 && !this.hasError(), true);
-                    this.startFade(this.controlBar, shouldShow, true);
+                    this.setupNewLoadState();
 
                     // Use the handleEvent() callback for all media events.
                     // The "error" event listener must capture, so that it can trap error events
                     // from the <source> children, which don't bubble.
                     for each (let event in this.videoEvents)
                         this.video.addEventListener(event, this, (event == "error") ? true : false);
 
                     var self = this;