diff --git a/dom/media/mediacontrol/MediaControlService.cpp b/dom/media/mediacontrol/MediaControlService.cpp index fe5e3e20f8ea..26cf0caa14f8 100644 --- a/dom/media/mediacontrol/MediaControlService.cpp +++ b/dom/media/mediacontrol/MediaControlService.cpp @@ -168,7 +168,7 @@ void MediaControlService::NotifyControllerPlaybackStateChanged( } } -void MediaControlService::NotifyControllerBeingUsedInPictureInPictureMode( +void MediaControlService::RequestUpdateMainController( MediaController* aController) { MOZ_DIAGNOSTIC_ASSERT(aController); MOZ_DIAGNOSTIC_ASSERT( diff --git a/dom/media/mediacontrol/MediaControlService.h b/dom/media/mediacontrol/MediaControlService.h index 6daa33487309..2ef639e7c244 100644 --- a/dom/media/mediacontrol/MediaControlService.h +++ b/dom/media/mediacontrol/MediaControlService.h @@ -51,10 +51,9 @@ class MediaControlService final : public nsIObserver { // This method would be called when the controller changes its playback state. void NotifyControllerPlaybackStateChanged(MediaController* aController); - // This method would be called when the controller starts to being used in the - // picture-in-picture mode. - void NotifyControllerBeingUsedInPictureInPictureMode( - MediaController* aController); + // This method is used to help a media controller become a main controller, if + // it fits the requirement. + void RequestUpdateMainController(MediaController* aController); // The main controller is the controller which can receive the media control // key events and would show its metadata to virtual controller interface. diff --git a/dom/media/mediacontrol/MediaController.cpp b/dom/media/mediacontrol/MediaController.cpp index 3108bebc55d2..6bc88eba8ca4 100644 --- a/dom/media/mediacontrol/MediaController.cpp +++ b/dom/media/mediacontrol/MediaController.cpp @@ -344,7 +344,7 @@ void MediaController::SetIsInPictureInPictureMode( UpdateActivatedStateIfNeeded(); if (RefPtr service = MediaControlService::GetService(); service && mIsInPictureInPictureMode) { - service->NotifyControllerBeingUsedInPictureInPictureMode(this); + service->RequestUpdateMainController(this); } UpdateDeactivationTimerIfNeeded(); mPictureInPictureModeChangedEvent.Notify(mIsInPictureInPictureMode); @@ -358,6 +358,10 @@ void MediaController::NotifyMediaFullScreenState(uint64_t aBrowsingContextId, LOG("%s fullscreen", aIsInFullScreen ? "Entered" : "Left"); mIsInFullScreenMode = aIsInFullScreen; UpdateActivatedStateIfNeeded(); + if (RefPtr service = MediaControlService::GetService(); + service && mIsInFullScreenMode) { + service->RequestUpdateMainController(this); + } mFullScreenChangedEvent.Notify(mIsInFullScreenMode); }