[iOS] While scrubbing and holding down, video continues to play
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 May 2015 00:45:00 +0000 (00:45 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 May 2015 00:45:00 +0000 (00:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144776
<rdar://problem/20863757>

Reviewed by Simon Fraser.

When we are scrubbing a video, we should pause playback. As we
let go of the scrubber playback can resume (but only if it was
playing originally).

* Modules/mediacontrols/mediaControlsiOS.js:
(ControllerIOS.prototype.createControls): Listen for touchstart on the scrubber.
(ControllerIOS.prototype.handleTimelineInput): Call the prototype, but pause if necessary.
(ControllerIOS.prototype.handleTimelineChange): Just moved this to be with the other timeline functions.
(ControllerIOS.prototype.handleTimelineTouchStart): Add the listeners for end and cancel. Remember that we are
potentially about to scrub.
(ControllerIOS.prototype.handleTimelineTouchEnd): Remove the listeners.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183965 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js

index 3928d0a..94a7be4 100644 (file)
@@ -1,3 +1,23 @@
+2015-05-07  Dean Jackson  <dino@apple.com>
+
+        [iOS] While scrubbing and holding down, video continues to play
+        https://bugs.webkit.org/show_bug.cgi?id=144776
+        <rdar://problem/20863757>
+
+        Reviewed by Simon Fraser.
+
+        When we are scrubbing a video, we should pause playback. As we
+        let go of the scrubber playback can resume (but only if it was
+        playing originally).
+
+        * Modules/mediacontrols/mediaControlsiOS.js:
+        (ControllerIOS.prototype.createControls): Listen for touchstart on the scrubber.
+        (ControllerIOS.prototype.handleTimelineInput): Call the prototype, but pause if necessary.
+        (ControllerIOS.prototype.handleTimelineChange): Just moved this to be with the other timeline functions.
+        (ControllerIOS.prototype.handleTimelineTouchStart): Add the listeners for end and cancel. Remember that we are
+        potentially about to scrub.
+        (ControllerIOS.prototype.handleTimelineTouchEnd): Remove the listeners.
+
 2015-05-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Applying a filter on an SVG element, which is larger than 4096 pixels, causes this element to be rendered shifted to the left
index 1d3b77c..8c4c205 100644 (file)
@@ -145,6 +145,7 @@ ControllerIOS.prototype = {
         this.listenFor(this.controls.optimizedFullscreenButton, 'touchstart', this.handleOptimizedFullscreenTouchStart);
         this.listenFor(this.controls.optimizedFullscreenButton, 'touchend', this.handleOptimizedFullscreenTouchEnd);
         this.listenFor(this.controls.optimizedFullscreenButton, 'touchcancel', this.handleOptimizedFullscreenTouchCancel);
+        this.listenFor(this.controls.timeline, 'touchstart', this.handleTimelineTouchStart);
         this.stopListeningFor(this.controls.playButton, 'click', this.handlePlayButtonClicked);
 
         this.controls.timeline.style.backgroundImage = '-webkit-canvas(' + this.timelineContextName + ')';
@@ -303,11 +304,6 @@ ControllerIOS.prototype = {
         return sign + String('0' + intMinutes).slice(intMinutes >= 10 ? -2 : -1) + ":" + String('0' + intSeconds).slice(-2);
     },
 
-    handleTimelineChange: function(event) {
-        Controller.prototype.handleTimelineChange.call(this);
-        this.updateProgress();
-    },
-
     handlePlayButtonTouchStart: function() {
         this.controls.playButton.classList.add('active');
     },
@@ -496,6 +492,32 @@ ControllerIOS.prototype = {
         return true;
     },
 
+    handleTimelineInput: function(event) {
+        if (this.potentiallyScrubbing)
+            this.video.pause();
+        Controller.prototype.handleTimelineInput.call(this, event);
+    },
+
+    handleTimelineChange: function(event) {
+        Controller.prototype.handleTimelineChange.call(this, event);
+        this.updateProgress();
+    },
+
+    handleTimelineTouchStart: function(event) {
+        this.potentiallyScrubbing = true;
+        this.wasPlayingWhenScrubbingStarted = !this.video.paused;
+        this.listenFor(this.controls.timeline, 'touchend', this.handleTimelineTouchEnd);
+        this.listenFor(this.controls.timeline, 'touchcancel', this.handleTimelineTouchEnd);
+    },
+
+    handleTimelineTouchEnd: function(event) {
+        this.stopListeningFor(this.controls.timeline, 'touchend', this.handleTimelineTouchEnd);
+        this.stopListeningFor(this.controls.timeline, 'touchcancel', this.handleTimelineTouchEnd);
+        this.potentiallyScrubbing = false;
+        if (this.wasPlayingWhenScrubbingStarted && this.video.paused)
+            this.video.play();
+    },
+
     handleReadyStateChange: function(event) {
         Controller.prototype.handleReadyStateChange.call(this, event);
         this.updateControls();