From 2b70308028ea22308c37d6ba00491f925d22180d Mon Sep 17 00:00:00 2001 From: jcass Date: Wed, 27 Jan 2016 07:19:23 +0200 Subject: [PATCH 1/2] Add event handling for 'muteChanged'. --- mopidy_musicbox_webclient/static/index.html | 2 +- mopidy_musicbox_webclient/static/js/controls.js | 16 ++++++++++------ .../static/js/functionsvars.js | 2 +- mopidy_musicbox_webclient/static/js/gui.js | 5 +++++ .../static/js/process_ws.js | 7 +++++++ mopidy_musicbox_webclient/static/mb.manifest | 2 +- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/mopidy_musicbox_webclient/static/index.html b/mopidy_musicbox_webclient/static/index.html index 27d3000..5392b4f 100644 --- a/mopidy_musicbox_webclient/static/index.html +++ b/mopidy_musicbox_webclient/static/index.html @@ -117,7 +117,7 @@
  • - + diff --git a/mopidy_musicbox_webclient/static/js/controls.js b/mopidy_musicbox_webclient/static/js/controls.js index 140157f..64c066c 100644 --- a/mopidy_musicbox_webclient/static/js/controls.js +++ b/mopidy_musicbox_webclient/static/js/controls.js @@ -424,15 +424,19 @@ function triggerVolume() { volumeChanging = 0; } -function toggleMute() { - mopidy.mixer.getMute().then(function(mute) { - mopidy.mixer.setMute(!mute); +function setMute(nwmute) { + if (mute != nwmute) { + mute = nwmute; if (mute) { - $("#mutebt").attr('class', 'fa fa-volume-up'); - } else { $("#mutebt").attr('class', 'fa fa-volume-off'); + } else { + $("#mutebt").attr('class', 'fa fa-volume-up'); } - }); + } +} + +function doMute() { + mopidy.mixer.setMute(!mute).then(); } /******* diff --git a/mopidy_musicbox_webclient/static/js/functionsvars.js b/mopidy_musicbox_webclient/static/js/functionsvars.js index a2ec0fd..490cbf2 100644 --- a/mopidy_musicbox_webclient/static/js/functionsvars.js +++ b/mopidy_musicbox_webclient/static/js/functionsvars.js @@ -13,7 +13,7 @@ var repeat; var consume; var single; var currentVolume = -1; -var muteVolume = -1; +var mute; var volumeChanging = false; var posChanging = false; diff --git a/mopidy_musicbox_webclient/static/js/gui.js b/mopidy_musicbox_webclient/static/js/gui.js index ade654b..d016e41 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -270,6 +270,10 @@ function initSocketevents() { } }); + mopidy.on("event:muteChanged", function(data) { + setMute(data["mute"]); + }); + mopidy.on("event:playbackStateChanged", function(data) { switch (data["new_state"]) { case "stopped": @@ -383,6 +387,7 @@ function updateStatusOfAll() { updateOptions() mopidy.playback.getVolume().then(processVolume, console.error); + mopidy.mixer.getMute().then(processMute, console.error); } function locationHashChanged() { diff --git a/mopidy_musicbox_webclient/static/js/process_ws.js b/mopidy_musicbox_webclient/static/js/process_ws.js index fe14d6b..6b9509a 100644 --- a/mopidy_musicbox_webclient/static/js/process_ws.js +++ b/mopidy_musicbox_webclient/static/js/process_ws.js @@ -21,6 +21,13 @@ function processVolume(data) { } } +/******************************************************** + * process results of mute + *********************************************************/ +function processMute(data) { + setMute(data); +} + /******************************************************** * process results of a repeat *********************************************************/ diff --git a/mopidy_musicbox_webclient/static/mb.manifest b/mopidy_musicbox_webclient/static/mb.manifest index 3f35151..110dd81 100644 --- a/mopidy_musicbox_webclient/static/mb.manifest +++ b/mopidy_musicbox_webclient/static/mb.manifest @@ -1,6 +1,6 @@ CACHE MANIFEST -# 2016-01-26:v1 +# 2016-01-27:v1 NETWORK: * From 9b76305e3f4cc3dbfdc941845e8bbded41a5b5fd Mon Sep 17 00:00:00 2001 From: jcass Date: Wed, 27 Jan 2016 07:21:12 +0200 Subject: [PATCH 2/2] Update changelog. Fixes #141. --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 2772a60..97e1138 100644 --- a/README.rst +++ b/README.rst @@ -64,6 +64,7 @@ v2.0.1 (UNRELEASED) - Add application cache manifest file for quicker loads and to allow client devices to detect when local caches should be invalidated. - Fix vertical alignment of playback control buttons in footer. - Use standard Mopidy mixer methods to mute / un-mute playback. +- Added event handling for 'muteChanged' event. (Fixes: `#141 `_). v2.0.0 (26-3-2015) ------------------