diff --git a/app/webroot/js/Player.js b/app/webroot/js/Player.js index 441616b..af38303 100644 --- a/app/webroot/js/Player.js +++ b/app/webroot/js/Player.js @@ -87,6 +87,7 @@ function Player() { if(audioElement.src != "") { audioElement.play(); } + this.notifyNowPlaying(); }; this.playIndex = function(index) { this.play(playlist.getByIndex(index).id); @@ -205,6 +206,19 @@ function Player() { this.isShuffle = function() { return shuffle; }; + this.notifyNowPlaying = function() { + if(Notification) { + Notification.requestPermission().then(function(permission) { + if (permission === 'granted') { + const replace = '_65x65' + (retina ? '@2x' : '') + '$1'; + new Notification(`Now playing: ${selected.title} (${selected.playtime})`, { + icon: selected.cover.replace(/(\.[a-z0-9]+)/i, replace), + body: `${selected.artist} / ${selected.album}` + }); + } + }); + } + }; } function Playlist() {