Skip to content

Commit

Permalink
fix(UI): Fix set MediaSession info when no previous Metadata (#7521)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Nov 12, 2024
1 parent 9987e5a commit 07abb2a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ui/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -1360,21 +1360,31 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
if (payload['key'] == 'APIC' && payload['mimeType'] == '-->') {
imageUrl = payload['data'];
}
if (navigator.mediaSession.metadata && title) {
const metadata = navigator.mediaSession.metadata;
metadata.title = title;
if (title) {
let metadata = {
title: title,
artwork: [],
};
if (navigator.mediaSession.metadata) {
metadata = navigator.mediaSession.metadata;
metadata.title = title;
}
navigator.mediaSession.metadata = new MediaMetadata(metadata);
}
if (imageUrl) {
const video = /** @type {HTMLVideoElement} */ (this.localVideo_);
if (imageUrl != video.poster) {
video.poster = imageUrl;
}
let metadata = {
title: '',
artwork: [{src: imageUrl}],
};
if (navigator.mediaSession.metadata) {
const metadata = navigator.mediaSession.metadata;
metadata = navigator.mediaSession.metadata;
metadata.artwork = [{src: imageUrl}];
navigator.mediaSession.metadata = new MediaMetadata(metadata);
}
navigator.mediaSession.metadata = new MediaMetadata(metadata);
}
});
}
Expand Down

0 comments on commit 07abb2a

Please sign in to comment.