From 6dea90de91cb5696d71b51956bdf0cb093351c08 Mon Sep 17 00:00:00 2001 From: Nicolas Berens Date: Mon, 12 Mar 2012 17:02:20 +0100 Subject: [PATCH 1/2] beginning of desktop notification. Code stolen from http://forum.subsonic.org/forum/viewtopic.php?p=22104#p22104 --- .../src/main/webapp/WEB-INF/jsp/playlist.jsp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp b/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp index 385ac1e8..0b155499 100644 --- a/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp +++ b/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp @@ -317,6 +317,37 @@ player.sendEvent("LOAD", list); player.sendEvent("PLAY"); + setNotification(song); + } + + function setNotification(song) + { + var n; + + //webkitNotifications + if (window.webkitNotifications.checkPermission() != 0) + { + setAllowNotification(); + return 0; + } + + n = window.webkitNotifications.createNotification('/icons/now_playing.png', song.title, song.artist + ' - ' + song.album); + n.ondisplay = function() { + setTimeout(function(){ + n.cancel(); + },5000); }; + n.show(); + } + + function setAllowNotification() + { + window.webkitNotifications.requestPermission(permissionGranted); + } + + function permissionGranted() + { + if (window.webkitNotifications.checkPermission() == 0) + setNotification(); } function updateCurrentImage() { From f3db9a715381d853a4b70b43a7d2636172785aae Mon Sep 17 00:00:00 2001 From: Nicolas Berens Date: Tue, 13 Mar 2012 15:08:47 +0100 Subject: [PATCH 2/2] Desktop notifications changes --- subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp b/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp index 0b155499..e895e105 100644 --- a/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp +++ b/subsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp @@ -223,7 +223,7 @@ } if ($("currentImage" + id) && song.streamUrl == currentStreamUrl) { - $("currentImage" + id).show(); + $("currentImage" + id).show(); } if ($("title" + id)) { dwr.util.setValue("title" + id, truncate(song.title)); @@ -324,7 +324,6 @@ { var n; - //webkitNotifications if (window.webkitNotifications.checkPermission() != 0) { setAllowNotification();