From 6dccab695cd981488ad211d398b7ee4674f97e93 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Thu, 11 Jul 2013 16:58:57 +0200 Subject: [PATCH] Bug 886173 - Preserve playbackRate across pause/play. r=cpearce --- content/html/content/src/HTMLMediaElement.cpp | 2 - content/media/test/Makefile.in | 1 + content/media/test/manifest.js | 1 - content/media/test/test_playback_rate.html | 36 +-------- .../test/test_playback_rate_playpause.html | 73 +++++++++++++++++++ toolkit/content/widgets/videocontrols.xml | 1 + 6 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 content/media/test/test_playback_rate_playpause.html diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index 86da5c2be9b0..0349b708750d 100644 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -2097,8 +2097,6 @@ HTMLMediaElement::Play(ErrorResult& aRv) } } - SetPlaybackRate(mDefaultPlaybackRate); - mPaused = false; mAutoplaying = false; // We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index dd220bb8f85e..e4c6ff73d5a2 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -140,6 +140,7 @@ MOCHITEST_FILES = \ test_VideoPlaybackQuality.html \ test_VideoPlaybackQuality_disabled.html \ test_webvtt_disabled.html \ + test_playback_rate_playpause.html \ $(NULL) # Disabled on Windows for frequent intermittent failures diff --git a/content/media/test/manifest.js b/content/media/test/manifest.js index 8b143e5e40d4..468d804beb40 100644 --- a/content/media/test/manifest.js +++ b/content/media/test/manifest.js @@ -38,7 +38,6 @@ var gProgressTests = [ // Used by test_played.html var gPlayedTests = [ { name:"big.wav", type:"audio/x-wav", duration:9.0 }, - { name:"sound.ogg", type:"audio/ogg", duration:4.0 }, { name:"seek.ogv", type:"video/ogg", duration:3.966 }, { name:"seek.webm", type:"video/webm", duration:3.966 }, { name:"gizmo.mp4", type:"video/mp4", duration:5.56 }, diff --git a/content/media/test/test_playback_rate.html b/content/media/test/test_playback_rate.html index e29455c4c1b4..1adf8074f56e 100644 --- a/content/media/test/test_playback_rate.html +++ b/content/media/test/test_playback_rate.html @@ -113,40 +113,7 @@ function onended(e) { ok(!t.muted, "The audio should be muted when playing at high speed, but should not appear as such."); is(t.currentTime, t.duration, "Current time should be equal to the duration (not change by playback rate)."); } - test_defaultPlaybackRate(e); -} - -function test_defaultPlaybackRate(e) { - var t = e.target; - t.currentTime = 0.0; - t.defaultPlaybackRate = SLOW_RATE; - t.addEventListener("timeupdate", ontimeupdate_defaultPlaybackRate); - t.startTimestamp = Date.now(); - t.play(); -} - -function ontimeupdate_defaultPlaybackRate(e) { - var t = e.target; - if (t.currentTime > t.duration / 10) { - t.oldCurrentTime = t.currentTime; - t.timestamp = Date.now(); - var delta = t.oldCurrentTime, - delta_wallclock = (t.timestamp - t.startTimestamp - t.bufferingTime) / 1000; - - t.bufferingTime = 0; - - is(t.playbackRate, SLOW_RATE, - "The playback rate shoud be "+SLOW_RATE+"." + t.token + '\n'); - is(t.defaultPlaybackRate, SLOW_RATE, - "The default playback rate shoud be "+SLOW_RATE+"." + t.token); - ok(delta_wallclock > delta , "We are effectively slowing down playback. (" + delta_wallclock + ", " + delta + ")"); - if (t.skippedFastPart) { - is(t.ratechangecount, 7, "We should have received 7 \"ratechange\" events."); - } else { - is(t.ratechangecount, 8, "We should have received 8 \"ratechange\" events."); - } - finish_test(t); - } + finish_test(t); } function onratechange(e) { @@ -207,7 +174,6 @@ function startTest(test, token) { element.playbackRate = VERY_SLOW_RATE; is(element.playbackRate, SLOW_RATE, "PlaybackRate should be clamped to " + SLOW_RATE + "."); element.play(); - is(element.playbackRate, 1.0, "playbackRate should be reset to 1.0 on play() call"); element.playbackRate = SLOW_RATE; }); } diff --git a/content/media/test/test_playback_rate_playpause.html b/content/media/test/test_playback_rate_playpause.html new file mode 100644 index 000000000000..b868a04b9051 --- /dev/null +++ b/content/media/test/test_playback_rate_playpause.html @@ -0,0 +1,73 @@ + + + + Test that the playbackRate property is not reset when resuming the playback + + + + + +
+
+
+
+
+ + diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index 33f1b4ecea35..1e4a544f307d 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -1004,6 +1004,7 @@ if (this.video.paused || this.video.ended) { this._triggeredByControls = true; this.hideClickToPlay(); + this.video.playbackRate = this.video.defaultPlaybackRate; this.video.play(); } else { this.video.pause();