summaryrefslogtreecommitdiffstats
path: root/dom/media/mediacontrol/MediaStatusManager.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /dom/media/mediacontrol/MediaStatusManager.cpp
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/mediacontrol/MediaStatusManager.cpp')
-rw-r--r--dom/media/mediacontrol/MediaStatusManager.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/dom/media/mediacontrol/MediaStatusManager.cpp b/dom/media/mediacontrol/MediaStatusManager.cpp
index 4365e6b531..9187e56f25 100644
--- a/dom/media/mediacontrol/MediaStatusManager.cpp
+++ b/dom/media/mediacontrol/MediaStatusManager.cpp
@@ -154,6 +154,7 @@ void MediaStatusManager::SetActiveMediaSessionContextId(
*mActiveMediaSessionContextId);
mMetadataChangedEvent.Notify(GetCurrentMediaMetadata());
mSupportedActionsChangedEvent.Notify(GetSupportedActions());
+ mPositionStateChangedEvent.Notify(GetCurrentPositionState());
if (StaticPrefs::media_mediacontrol_testingevents_enabled()) {
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
obs->NotifyObservers(nullptr, "active-media-session-changed", nullptr);
@@ -170,6 +171,7 @@ void MediaStatusManager::ClearActiveMediaSessionContextIdIfNeeded() {
StoreMediaSessionContextIdOnWindowContext();
mMetadataChangedEvent.Notify(GetCurrentMediaMetadata());
mSupportedActionsChangedEvent.Notify(GetSupportedActions());
+ mPositionStateChangedEvent.Notify(GetCurrentPositionState());
if (StaticPrefs::media_mediacontrol_testingevents_enabled()) {
if (nsCOMPtr<nsIObserverService> obs = services::GetObserverService()) {
obs->NotifyObservers(nullptr, "active-media-session-changed", nullptr);
@@ -362,8 +364,14 @@ void MediaStatusManager::DisableAction(uint64_t aBrowsingContextId,
NotifySupportedKeysChangedIfNeeded(aBrowsingContextId);
}
-void MediaStatusManager::UpdatePositionState(uint64_t aBrowsingContextId,
- const PositionState& aState) {
+void MediaStatusManager::UpdatePositionState(
+ uint64_t aBrowsingContextId, const Maybe<PositionState>& aState) {
+ auto info = mMediaSessionInfoMap.Lookup(aBrowsingContextId);
+ if (info) {
+ LOG("Update position state for context %" PRIu64, aBrowsingContextId);
+ info->mPositionState = aState;
+ }
+
// The position state comes from non-active media session which we don't care.
if (!mActiveMediaSessionContextId ||
*mActiveMediaSessionContextId != aBrowsingContextId) {
@@ -393,9 +401,8 @@ CopyableTArray<MediaSessionAction> MediaStatusManager::GetSupportedActions()
MediaSessionInfo info =
mMediaSessionInfoMap.Get(*mActiveMediaSessionContextId);
- const uint8_t actionNums = uint8_t(MediaSessionAction::EndGuard_);
- for (uint8_t actionValue = 0; actionValue < actionNums; actionValue++) {
- MediaSessionAction action = ConvertToMediaSessionAction(actionValue);
+ for (MediaSessionAction action :
+ MakeWebIDLEnumeratedRange<MediaSessionAction>()) {
if (info.IsActionSupported(action)) {
supportedActions.AppendElement(action);
}
@@ -421,6 +428,16 @@ MediaMetadataBase MediaStatusManager::GetCurrentMediaMetadata() const {
return CreateDefaultMetadata();
}
+Maybe<PositionState> MediaStatusManager::GetCurrentPositionState() const {
+ if (mActiveMediaSessionContextId) {
+ auto info = mMediaSessionInfoMap.Lookup(*mActiveMediaSessionContextId);
+ if (info) {
+ return info->mPositionState;
+ }
+ }
+ return Nothing();
+}
+
void MediaStatusManager::FillMissingTitleAndArtworkIfNeeded(
MediaMetadataBase& aMetadata) const {
// If the metadata doesn't set its title and artwork properly, we would like