Skip to content

Commit

Permalink
[player]: add metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
tachibana-shin committed May 20, 2023
1 parent eda2c03 commit af5e95e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/BrtPlayer.vue
Expand Up @@ -2410,6 +2410,26 @@ useEventListener(window, "keydown", (event: KeyboardEvent) => {
break
}
})
if (typeof MediaMetadata !== "undefined" && navigator.mediaSession)
watchEffect(() => {
if (!props.nameCurrentChap || !props.name || !props.poster) return
const title = t("tap-_chap-_name-_othername", [
props.nameCurrentChap,
props.name,
"",
])
navigator.mediaSession.metadata = new MediaMetadata({
title,
artist: props.name,
artwork: [
{
src: props.poster,
},
],
})
})
// keybind for headphone control
navigator.mediaSession?.setActionHandler("pause", () => {
const playing = artPlaying.value
Expand Down

0 comments on commit af5e95e

Please sign in to comment.