Bug 1733902 - part2 : use the new method to check if we should delay media from starting playback. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D128127
This commit is contained in:
alwu 2021-11-01 22:26:40 +00:00
Родитель 28430fb0d3
Коммит b9abcddbc1
4 изменённых файлов: 4 добавлений и 19 удалений

Просмотреть файл

@ -267,8 +267,8 @@ AudioPlaybackConfig AudioChannelService::GetMediaConfig(
}
config.mMuted = config.mMuted || window->GetAudioMuted();
if (window->GetMediaSuspend() != nsISuspendedTypes::NONE_SUSPENDED) {
config.mSuspend = window->GetMediaSuspend();
if (window->ShouldDelayMediaFromStart()) {
config.mSuspend = nsISuspendedTypes::SUSPENDED_BLOCK;
}
nsCOMPtr<nsPIDOMWindowOuter> win =
@ -599,8 +599,7 @@ void AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(
return;
}
if (window->GetMediaSuspend() != nsISuspendedTypes::SUSPENDED_BLOCK ||
!doc->Hidden()) {
if (!window->ShouldDelayMediaFromStart() || !doc->Hidden()) {
return;
}

Просмотреть файл

@ -3055,15 +3055,6 @@ bool nsPIDOMWindowOuter::ShouldDelayMediaFromStart() const {
return bc && bc->Top()->GetShouldDelayMediaFromStart();
}
SuspendTypes nsPIDOMWindowOuter::GetMediaSuspend() const {
// TODO : replace this by `ShouldDelayMediaFromStart` in following patch.
BrowsingContext* bc = GetBrowsingContext();
if (bc && bc->Top()->GetShouldDelayMediaFromStart()) {
return nsISuspendedTypes::SUSPENDED_BLOCK;
}
return nsISuspendedTypes::NONE_SUSPENDED;
}
void nsPIDOMWindowOuter::NotifyResumingDelayedMedia() {
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (service) {

Просмотреть файл

@ -780,8 +780,6 @@ class nsPIDOMWindowOuter : public mozIDOMWindowProxy {
bool IsBackground() { return mIsBackground; }
// Audio API
SuspendTypes GetMediaSuspend() const;
bool GetAudioMuted() const;
// No longer to delay media from starting for this window.

Просмотреть файл

@ -152,10 +152,7 @@ bool MediaPlaybackDelayPolicy::ShouldDelayPlayback(
const Document* doc = aElement->OwnerDoc();
nsPIDOMWindowInner* inner = nsPIDOMWindowInner::From(doc->GetInnerWindow());
nsPIDOMWindowOuter* outer = nsPIDOMWindowOuter::GetFromCurrentInner(inner);
if (!outer) {
return false;
}
return outer->GetMediaSuspend() == nsISuspendedTypes::SUSPENDED_BLOCK;
return outer && outer->ShouldDelayMediaFromStart();
}
RefPtr<ResumeDelayedPlaybackAgent>