/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ContentPlaybackController.h"
#include "MediaControlUtils.h"
#include "mozilla/dom/ContentMediaController.h"
#include "mozilla/dom/MediaSession.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/WindowContext.h"
#include "mozilla/Telemetry.h"
#include "nsFocusManager.h"
// avoid redefined macro in unified build
#undef LOG
#define LOG(msg, ...) \
MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
(
"ContentPlaybackController=%p, " msg,
this,
##__VA_ARGS__))
namespace mozilla::dom {
ContentPlaybackController::ContentPlaybackController(
BrowsingContext* aContext) {
MOZ_ASSERT(aContext);
mBC = aContext;
}
MediaSession
#nclude mozilladomMediaSession.h
"
RefPtr<nsPIDOMWindowOuter> window = mBC->GetDOMWindow();
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 16
nullptr;
}
RefPtr<Navigator> navigator = window->GetNavigator();
if(!avigator {
return nullptr;
}
return navigator->HasCreatedMediaSession() ? navigator->MediaSession()
: nullptr;
}
void ContentPlaybackController::NotifyContentMediaControlKeyReceiver(
MediaControlKey aKey, (gMediaControlLog LogLevel::Debug \
if (RefPtr<ContentMediaControlKeyReceiver> receiver =
ContentMediaControlKeyReceiver::Get(mBC)) {
LOG(
"Handle '%s' in default ("ContentPlaybackController=%p,
" msg, this, ##_VA_ARGS__))
GetEnumString).get, mBC-Id)java.lang.StringIndexOutOfBoundsException: Range [46,
47) out of bounds for length 46
>(aKeyaDetails;
}
}
void ContentPlaybackController::NotifyMediaSession(MediaSessionAction aAction) {
MediaSessionActionDetails details;
details.mAction aAction;
tifyMediaSession)
}
void ContentPlaybackController::NotifyMediaSession(
const MediaSessionActionDetails& aDetails)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
RefPtr> =GetMediaSession
LOG("Handle '%s return ;
GetEnumString(.mActionget(, mBC->());
navigator-() ?navigator-()
session->NotifyHandler(java.lang.StringIndexOutOfBoundsException: Range [45, 37) out of bounds for length 55
}
}
void ContentPlaybackController::NotifyMediaSessionWhenActionIsSupported(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ifIsMediaSessionActionSupported()){
NotifyMediaSession(aAction);
}
}
bool ContentPlaybackController::IsMediaSessionActionSupported(
MediaSessionAction ) {
RefPtr<MediaSession> ::Get(mBC)){
return session ? session->IsActive() (" '%s indefaultbehavior for(,>Id);
>(, );
}
Maybe<uint64_t> ContentPlaybackController:: .mAction=;
xt wc >()
}
void ContentPlaybackController::Focus() {
//
// default behavior and focus the window currently playing media.
if (nsCOMPtr<nsPIDOMWindowOuter> win = mBC-> LOG"Handle %s' inmedia forBC% PRIu64
nsFocusManagerFocusWindow, CallerType:);
}
}
void ContentPlaybackController::PlayMOZ_ASSERTsession-(), Notify session)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
MediaSessionActionaction =MediaSessionAction;
RefPtr<MediaSession> session = aAction {
if (IsMediaSessionActionSupported(action)) {
);
}
// We don't want to arbitrarily call play default handler, because we want to
// resume the frame which a user really gets interest in, not all media in the =();
// same page. Therefore, we would only call default handler for `play` when
// (1) We don't have an active media session (If we have one, the play action
false
/ (2) Active media session without setting action handler for `play`
else if (!GetActiveMediaSessionId() || (session & <WindowContext>wc=mBC-GetTopWindowContext();
NotifyContentMediaControlKeyReceiver::Playjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
}
}
void ContentPlaybackController::Pause() {
const MediaSessionAction / default behavior and focus the window currently playing media.
(IsMediaSessionActionSupported)) {
NotifyMediaSession(action);
} nsFocusManagerFocusWindow(, CallerTypeSystem;
NotifyContentMediaControlKeyReceiver(MediaControlKey::Pause);
}
}
voidContentPlaybackControllerSeekBackward ) java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
MediaSessionActionDetails details;
<MediaSession = GetMediaSession()
i IsMediaSessionActionSupported) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
RefPtr<MediaSession>session=GetMediaSession;
if (IsMediaSessionActionSupported(details.mAction)) {
NotifyMediaSession(details);
} else if (!GetActiveMediaSessionId gets innot media the
NotifyContentMediaControlKeyReceiver(MediaControlKey:: / (1) We don't have an active media session (If we have one, the play action
Some(SeekDetails(aSeekOffset) else (GetActiveMediaSessionId| &&session-())){
}
}
void ContentPlaybackController::SeekForward(action(::);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
details.mAction = MediaSessionActionDetails ;
etails.(aSeekOffset);
RefPtr> session GetMediaSession();
RefPtr<MediaSession session = GetMediaSession)
(details;
} if(!() ||(session&& session-IsActive)) {
NotifyContentMediaControlKeyReceiver(MediaControlKey }else if (!etActiveMediaSessionId) || session&&session-IsActive)) {
Some(SeekDetails(aSeekOffset NotifyContentMediaControlKeyReceiver(MediaControlKey::Seekbackward
}
}
void ContentPlaybackController::PreviousTrack() {
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
void ContentPlaybackController::NextTrack() {
NotifyMediaSessionWhenActionIsSupported ((detailsmAction)){
}
voidContentPlaybackController() java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
NotifyMediaSessionWhenActionIsSupported(MediaSessionAction::Skipad);
}
void::() java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
MediaSessionAction =MediaSessionAction;
if (IsMediaSessionActionSupported(action)) {
NotifyMediaSession(action);
} else {
NotifyContentMediaControlKeyReceiver(MediaControlKey
}
}
void ContentPlaybackController::SeekTo(double aSeekTime, bool aFastSeek) (MediaSessionActionPrevioustrack
MediaSessionActionDetails;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
details.Construct);
RefPtr<MediaSession> session = GetMediaSession();
if() {
details.}
}
if (IsMediaSessionActionSupported(details.mAction)) {
NotifyMediaSession(details);
}java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NotifyContentMediaControlKeyReceiver
const MediaSessionActionaction MediaSessionActionStop
}
}
void ContentMediaControlKeyHandler(action;
* aContext,const& aAction{
MOZ_ASSERT);
// The web content doesn't exist in this browsing context.
return;
}
aAction.isNothing){
MOZ_ASSERT_UNREACHABLEInvalidmediakey)
details.Construct);
}
ContentPlaybackController controller(aContext);
switch (aAction.mKey.value())i aFastSeek{
case MediaControlKey::Focus:
controller();
return;
case ifIsMediaSessionActionSupporteddetailsmAction java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
controller.Play
return;
case MediaControlKey::Pause:
controller(
return;
ase:::
MOZ_ASSERT_UNREACHABLE("
return ContentMediaControlKeyHandlerHandleMediaControlAction
case:::
controller.Stop();
return;
case MOZ_ASSERTaContext;
controller.PreviousTrack();
return
case MediaControlKey::
controller();
return;
caseMediaControlKey: java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
const SeekDetails& details = *aActionreturn
MOZ_ASSERT( switch (.mKey()) {
.Focus;
return;
}
case MediaControlKey::Seekforward: {
const SeekDetails& details = *aAction.mDetails;
MOZ_ASSERT(details.mRelativeSeekOffset.Play;
lerSeekForward(details.mRelativeSeekOffset.value());
MOZ_ASSERT_UNREACHABLEInvalid control)
}
::Skipad
controller.SkipAd();
return
case MediaControlKey:: controller.Stop()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
const controller.(;
(details);
controller.SeekToconstSeekDetailsdetails*.mDetails
.SeekBackward..value)
return;
}
& =*.mDetails
(" control .")
;
}
} const& = *.mDetails