From 86809dcc62bcd422976c06e758edb1924c178c86 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 1 Jan 2025 09:02:31 -0600 Subject: [PATCH] Update audio player to pass chapterInfo to media session API --- .../components/app/MediaPlayerContainer.vue | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/client/components/app/MediaPlayerContainer.vue b/client/components/app/MediaPlayerContainer.vue index ed8971f7..989fc062 100644 --- a/client/components/app/MediaPlayerContainer.vue +++ b/client/components/app/MediaPlayerContainer.vue @@ -374,19 +374,27 @@ export default { return } + // https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API if ('mediaSession' in navigator) { - var coverImageSrc = this.$store.getters['globals/getLibraryItemCoverSrc'](this.streamLibraryItem, '/Logo.png', true) - const artwork = [ - { - src: coverImageSrc - } - ] + const chapterInfo = [] + if (this.chapters.length) { + this.chapters.forEach((chapter) => { + chapterInfo.push({ + title: chapter.title, + startTime: chapter.start + }) + }) + } navigator.mediaSession.metadata = new MediaMetadata({ title: this.title, artist: this.playerHandler.displayAuthor || this.mediaMetadata.authorName || 'Unknown', album: this.mediaMetadata.seriesName || '', - artwork + artwork: [ + { + src: this.$store.getters['globals/getLibraryItemCoverSrc'](this.streamLibraryItem, '/Logo.png', true) + } + ] }) console.log('Set media session metadata', navigator.mediaSession.metadata)