Merge pull request #142 from jcass77/fix/mute_events

Add event handling for 'muteChanged' event
This commit is contained in:
Nick Steel 2016-01-28 19:04:13 +00:00
commit c9fa8b3bbe
7 changed files with 26 additions and 9 deletions

View File

@ -79,6 +79,7 @@ v2.1.0 (UNRELEASED)
- Add application cache manifest file for quicker loads and to allow client devices to detect when local caches should
be invalidated.
- Use standard Mopidy mixer methods to mute / un-mute playback.
- Added event handling for 'muteChanged' event. (Fixes: `#141 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/141>`_).
**Fixes**

View File

@ -117,7 +117,7 @@
</li>
<li id="" data-icon="false">
<div><!-- slider for volume -->
<a href="#" onclick="toggleMute(); return false;"><span title="Toggle mute"><i id="mutebt" class="fa fa-volume-up"></i></span></a>
<a href="#" onclick="doMute(); return false;"><span title="Toggle mute"><i id="mutebt" class="fa fa-volume-up"></i></span></a>
<label for="volumeslider" class="ui-hidden-accessible">Volume</label>
<input id="volumeslider" data-highlight="true" name="volumeslider" data-mini="true" type="range" min="0"
value="0" max="100" onchange="doVolume(this.value);"/>

View File

@ -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();
}
/*******

View File

@ -13,7 +13,7 @@ var repeat;
var consume;
var single;
var currentVolume = -1;
var muteVolume = -1;
var mute;
var volumeChanging = false;
var posChanging = false;

View File

@ -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() {

View File

@ -21,6 +21,13 @@ function processVolume(data) {
}
}
/********************************************************
* process results of mute
*********************************************************/
function processMute(data) {
setMute(data);
}
/********************************************************
* process results of a repeat
*********************************************************/

View File

@ -1,6 +1,6 @@
CACHE MANIFEST
# 2016-01-26:v1
# 2016-01-27:v1
NETWORK:
*