Commit ef28e2a3 authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Autoplay muted: fix visibility detection when the source was changed.

The autoplay visibility observer is reset in various situations but
wasn't when the source of the video was change which broke use cases
such as playing A then switching to B. B would freeze to the first frame
and never update.

Bug: 804091
Change-Id: I984d4c5d67c575d3c45f50877d329264c1a6020e
Reviewed-on: https://chromium-review.googlesource.com/890942Reviewed-by: default avatarapacible <apacible@chromium.org>
Commit-Queue: Mounir Lamouri (slow) <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532828}
parent d8789f93
<!DOCTYPE html>
<title>Test that the autoplay muted via attribute allows change in src</title>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../media-file.js'></script>
<video muted autoplay></video>
<script>
async_test(t => {
t.add_cleanup(() => {
window.internals.settings.setAutoplayPolicy('no-user-gesture-required');
window.internals.runtimeFlags.autoplayMutedVideosEnabled = false;
});
window.internals.settings.setAutoplayPolicy('document-user-activation-required');
window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
var video = document.querySelector('video');
video.src = findMediaFile('video', '../content/test');
video.addEventListener('play', t.step_func(e => {
setTimeout(t.step_func(() => {
video.src = findMediaFile('video', '../content/counting');
video.addEventListener('play', t.step_func_done());
}));
}), { once: true });
});
</script>
......@@ -829,6 +829,8 @@ void HTMLMediaElement::InvokeLoadAlgorithm() {
have_fired_loaded_data_ = false;
display_mode_ = kUnknown;
autoplay_policy_->StopAutoplayMutedWhenVisible();
// 1 - Abort any already-running instance of the resource selection algorithm
// for this element.
load_state_ = kWaitingForSource;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment