Merge pull request #142 from jcass77/fix/mute_events
Add event handling for 'muteChanged' event
This commit is contained in:
commit
c9fa8b3bbe
@ -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**
|
||||
|
||||
|
||||
@ -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);"/>
|
||||
|
||||
16
mopidy_musicbox_webclient/static/js/controls.js
vendored
16
mopidy_musicbox_webclient/static/js/controls.js
vendored
@ -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();
|
||||
}
|
||||
|
||||
/*******
|
||||
|
||||
@ -13,7 +13,7 @@ var repeat;
|
||||
var consume;
|
||||
var single;
|
||||
var currentVolume = -1;
|
||||
var muteVolume = -1;
|
||||
var mute;
|
||||
var volumeChanging = false;
|
||||
var posChanging = false;
|
||||
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -21,6 +21,13 @@ function processVolume(data) {
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* process results of mute
|
||||
*********************************************************/
|
||||
function processMute(data) {
|
||||
setMute(data);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* process results of a repeat
|
||||
*********************************************************/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
CACHE MANIFEST
|
||||
|
||||
# 2016-01-26:v1
|
||||
# 2016-01-27:v1
|
||||
|
||||
NETWORK:
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user