diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 26719f058e97..ecd0405d554a 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -7763,6 +7763,20 @@ void HTMLMediaElement::CreateStopMediaControlTimerIfNeeded() { !mMediaControlEventListener->IsStarted()) { return; } + + // As the media element being used in the PIP mode would always display on the + // screen, users would have high chance to interact with it again, so we don't + // want to stop media control. + if (IsBeingUsedInPictureInPictureMode()) { + MEDIACONTROL_LOG("No need to create a timer for PIP video."); + return; + } + + if (!Paused()) { + MEDIACONTROL_LOG("No need to create a timer for playing media."); + return; + } + MEDIACONTROL_LOG("Start stop media control timer"); NS_NewTimerWithFuncCallback( getter_AddRefs(mStopMediaControlTimer), StopMediaControlTimerCallback, diff --git a/dom/html/HTMLVideoElement.cpp b/dom/html/HTMLVideoElement.cpp index 45ab8b901944..9f0a7081c93b 100644 --- a/dom/html/HTMLVideoElement.cpp +++ b/dom/html/HTMLVideoElement.cpp @@ -582,6 +582,8 @@ void HTMLVideoElement::EndCloningVisually() { Unused << mVisualCloneTarget->SetVisualCloneSource(nullptr); Unused << SetVisualCloneTarget(nullptr); + CreateStopMediaControlTimerIfNeeded(); + if (IsInComposedDoc() && !StaticPrefs::media_cloneElementVisually_testing()) { NotifyUAWidgetSetupOrChange(); }