diff --git a/assets/js/app.js b/assets/js/app.js index 476cdc1..bc622f0 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -116,7 +116,7 @@ Hooks.AudioPlayer = { this.play() } }) - this.handleEvent("play", ({url, token, elapsed}) => { + this.handleEvent("play", ({url, token, elapsed, artist, title}) => { this.playbackBeganAt = nowSeconds() - elapsed let currentSrc = this.player.src.split("?")[0] if(currentSrc === url && this.player.paused){ @@ -125,6 +125,10 @@ Hooks.AudioPlayer = { this.player.src = `${url}?token=${token}` this.play({sync: true}) } + + if("mediaSession" in navigator){ + navigator.mediaSession.metadata = new MediaMetadata({artist, title}) + } }) this.handleEvent("pause", () => this.pause()) this.handleEvent("stop", () => this.stop()) diff --git a/lib/live_beats_web/live/player_live.ex b/lib/live_beats_web/live/player_live.ex index 7e1ba91..aba490c 100644 --- a/lib/live_beats_web/live/player_live.ex +++ b/lib/live_beats_web/live/player_live.ex @@ -314,6 +314,8 @@ defmodule LiveBeatsWeb.PlayerLive do }) push_event(socket, "play", %{ + artist: song.artist, + title: song.title, paused: Song.paused?(song), elapsed: elapsed, duration: song.duration,