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

Autoplay: add Feature/Runtime flags to turn on/off restrictions on Web Audio.

This is adding a flag to be able to control whether Web Audio should be
restricted by autoplay. It will allow testing and experimenting.

Bug: 841933
Change-Id: Icdec2e74b210f0cf49db87f79ac9a1cb60d94d63
Reviewed-on: https://chromium-review.googlesource.com/1067148Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560350}
parent a19d7e5d
......@@ -452,6 +452,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnableOriginTrialControlledFeatures(false);
}
WebRuntimeFeatures::EnableAutoplayIgnoresWebAudio(
base::FeatureList::IsEnabled(media::kAutoplayIgnoreWebAudio));
// Enable explicitly enabled features, and then disable explicitly disabled
// ones.
for (const std::string& feature :
......
......@@ -320,6 +320,12 @@ const base::Feature kLowDelayVideoRenderingOnLiveStream{
"low-delay-video-rendering-on-live-stream",
base::FEATURE_ENABLED_BY_DEFAULT};
// Whether the autoplay policy should ignore Web Audio. When ignored, the
// autoplay policy will be hardcoded to be the legacy one on based on the
// platform
const base::Feature kAutoplayIgnoreWebAudio{"AutoplayIgnoreWebAudio",
base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_ANDROID)
// Lock the screen orientation when a video goes fullscreen.
const base::Feature kVideoFullscreenOrientationLock{
......
......@@ -104,6 +104,7 @@ namespace media {
// All features in alphabetical order. The features should be documented
// alongside the definition of their values in the .cc file.
MEDIA_EXPORT extern const base::Feature kAutoplayIgnoreWebAudio;
MEDIA_EXPORT extern const base::Feature kAv1Decoder;
MEDIA_EXPORT extern const base::Feature kBackgroundVideoPauseOptimization;
MEDIA_EXPORT extern const base::Feature kBackgroundVideoTrackOptimization;
......
......@@ -191,6 +191,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableOffMainThreadWebSocket(bool);
BLINK_PLATFORM_EXPORT static void EnableExperimentalProductivityFeatures(
bool);
BLINK_PLATFORM_EXPORT static void EnableAutoplayIgnoresWebAudio(bool);
private:
WebRuntimeFeatures();
......
......@@ -684,13 +684,19 @@ Document* BaseAudioContext::GetDocument() const {
}
AutoplayPolicy::Type BaseAudioContext::GetAutoplayPolicy() const {
// The policy is different on Android compared to Desktop.
if (RuntimeEnabledFeatures::AutoplayIgnoresWebAudioEnabled()) {
// When ignored, the policy is different on Android compared to Desktop.
#if defined(OS_ANDROID)
return AutoplayPolicy::Type::kUserGestureRequired;
#else
// Force no user gesture required on desktop.
return AutoplayPolicy::Type::kNoUserGestureRequired;
#endif
}
Document* document = GetDocument();
DCHECK(document);
return AutoplayPolicy::GetAutoplayPolicyForDocument(*document);
}
bool BaseAudioContext::AreAutoplayRequirementsFulfilled() const {
......
......@@ -520,4 +520,8 @@ void WebRuntimeFeatures::EnableDisplayCutoutViewportFit(bool enable) {
RuntimeEnabledFeatures::SetDisplayCutoutViewportFitEnabled(enable);
}
void WebRuntimeFeatures::EnableAutoplayIgnoresWebAudio(bool enable) {
RuntimeEnabledFeatures::SetAutoplayIgnoresWebAudioEnabled(enable);
}
} // namespace blink
......@@ -112,6 +112,10 @@
name: "AutomationControlled",
settable_from_internals: true,
},
{
// Flag set by the media::kAutoplayIgnoreWebAudio feature flag.
name: "AutoplayIgnoresWebAudio",
},
{
name: "AutoplayMutedVideos",
settable_from_internals: true,
......
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