зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434804 - Pause autoplayed media if they become audible. r=kamidphish
Our autoplay blocking is trivial to defeat; just mute or volume=0 a video, play(), and then unmute, and then you're playing audibly. So this patch makes us pause() media that become audible atfter playback has started. MozReview-Commit-ID: 2RAtbohMGJO --HG-- extra : rebase_source : 021510102374185debc89610bc6027206a0af6fc
This commit is contained in:
Родитель
0cc7aa3f8f
Коммит
f589142a62
|
@ -2971,6 +2971,10 @@ HTMLMediaElement::SetVolume(double aVolume, ErrorResult& aRv)
|
|||
SetVolumeInternal();
|
||||
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("volumechange"));
|
||||
|
||||
// We allow inaudible autoplay. But changing our volume may make this
|
||||
// media audible. So pause if we are no longer supposed to be autoplaying.
|
||||
PauseIfShouldNotBePlaying();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3019,6 +3023,18 @@ HTMLMediaElement::SetMutedInternal(uint32_t aMuted)
|
|||
SetVolumeInternal();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::PauseIfShouldNotBePlaying()
|
||||
{
|
||||
if (GetPaused()) {
|
||||
return;
|
||||
}
|
||||
if (!AutoplayPolicy::IsMediaElementAllowedToPlay(WrapNotNull(this))) {
|
||||
ErrorResult rv;
|
||||
Pause(rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::SetVolumeInternal()
|
||||
{
|
||||
|
@ -3051,6 +3067,10 @@ HTMLMediaElement::SetMuted(bool aMuted)
|
|||
}
|
||||
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("volumechange"));
|
||||
|
||||
// We allow inaudible autoplay. But changing our mute status may make this
|
||||
// media audible. So pause if we are no longer supposed to be autoplaying.
|
||||
PauseIfShouldNotBePlaying();
|
||||
}
|
||||
|
||||
class HTMLMediaElement::StreamCaptureTrackSource :
|
||||
|
|
|
@ -1368,6 +1368,8 @@ protected:
|
|||
void SetCDMProxyFailure(const MediaResult& aResult);
|
||||
void ResetSetMediaKeysTempVariables();
|
||||
|
||||
void PauseIfShouldNotBePlaying();
|
||||
|
||||
// The current decoder. Load() has been called on this decoder.
|
||||
// At most one of mDecoder and mSrcStream can be non-null.
|
||||
RefPtr<MediaDecoder> mDecoder;
|
||||
|
|
Загрузка…
Ссылка в новой задаче