diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index bae9d8f0c59a..9ef52f1565dc 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -831,9 +831,11 @@ static PRBool IsAutoplayEnabled() void nsHTMLMediaElement::UpdatePreloadAction() { PreloadAction nextAction = PRELOAD_UNDEFINED; - // If autoplay is set, we should always preload data, as we'll need it - // to play. - if (IsAutoplayEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) { + // If autoplay is set, or we're playing, we should always preload data, + // as we'll need it to play. + if ((IsAutoplayEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) || + !mPaused) + { nextAction = nsHTMLMediaElement::PRELOAD_ENOUGH; } else { // Find the appropriate preload action by looking at the attribute. @@ -1394,7 +1396,9 @@ NS_IMETHODIMP nsHTMLMediaElement::Play() mPaused = PR_FALSE; mAutoplaying = PR_FALSE; // We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference + // and our preload status. AddRemoveSelfReference(); + UpdatePreloadAction(); return NS_OK; } diff --git a/content/media/test/test_preload_actions.html b/content/media/test/test_preload_actions.html index 4172c4cfa9ae..230fa4335396 100644 --- a/content/media/test/test_preload_actions.html +++ b/content/media/test/test_preload_actions.html @@ -535,6 +535,27 @@ var tests = [ v.src = test.name; }, }, + { + // 18. On a preload='none' video, call play() before load algorithms's sync + // has run, the play() call should override preload='none'. + ended: + function(e) { + ok(true, "(18) Got playback ended."); + var v = e.target; + v._finished = true; + maybeFinish(v, 18); + }, + + setup: + function(v) { + v.addEventListener("ended", this.ended, false); + v._finished = false; + v.preload = "none"; + v.src = test.name; // Schedules async section to continue load algorithm. + document.body.appendChild(v); + v.play(); // Should cause preload:none to be overridden. + }, + } ]; function startTest(test, token) {