Skip to content

Commit

Permalink
Add shuffle support
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Jimenez Esun committed Apr 14, 2020
1 parent 1329ce7 commit f1b96da
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
12 changes: 12 additions & 0 deletions bin/service/music-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ module.exports = class MusicServer {
case /(?:^|\/)audio\/\d+\/queueplus(?:\/|$)/.test(url):
return this._audioQueuePlus(url);

case /(?:^|\/)audio\/\d+\/shuffle\/\d+(?:\/|$)/.test(url):
return this._audioShuffle(url);

case /(?:^|\/)audio\/\d+\/volume\/[+-]?\d+(?:\/|$)/.test(url):
return this._audioVolume(url);

Expand Down Expand Up @@ -305,6 +308,15 @@ module.exports = class MusicServer {
return this._audioCfgGetPlayersDetails('audio/cfg/getplayersdetails');
}

_audioShuffle(url) {
const [, zoneId, , shuffle] = url.split('/');
const zone = this._zones[+zoneId - 1];

zone.setShuffle(!!+shuffle);

return this._audioCfgGetPlayersDetails('audio/cfg/getplayersdetails');
}

_audioVolume(url) {
const [, zoneId, , volume] = url.split('/');
const zone = this._zones[+zoneId - 1];
Expand Down
13 changes: 13 additions & 0 deletions bin/service/music-server/music-zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = class MusicZone {
this._duration = 0;
this._mode = 'stop';
this._queueIndex = 0;
this._shuffle = false;
this._time = 0;
this._title = '';
this._volume = 50;
Expand All @@ -27,6 +28,7 @@ module.exports = class MusicZone {
coverurl: this.getCover(),
duration: this.getDuration(),
mode: this.getMode(),
plshuffle: this.getShuffle(),
power: 'on',
station: '',
time: this.getTime(),
Expand Down Expand Up @@ -118,6 +120,17 @@ module.exports = class MusicZone {
this._sendAudioEvent();
}

setShuffle(shuffle) {
this._shuffle = !!shuffle;

this._sendPlayerCommand('shuffle', this._shuffle ? 1 : 0);
this._sendAudioEvent();
}

getShuffle() {
return this._shuffle;
}

getTitle() {
return this._title;
}
Expand Down
11 changes: 6 additions & 5 deletions webfrontend/htmlauth/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@
$vo .= "<VirtualOut Title=\"Music server $id\" Comment=\"\" Address=\"/dev/udp/&lt;LOXBERRY_IP&gt;/$port\" CmdInit=\"\" CloseAfterSend=\"false\" CmdSep=\";\">";

for ($zone = 1; $zone <= $cfg["data"]["music-server-$id-zones"]; $zone++) {
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, play\" Comment=\"\" Address=\"\" Check=\"$zone::play\" Signed=\"true\" Analog=\"false\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"100\" DestValHigh=\"100\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, pause\" Comment=\"\" Address=\"\" Check=\"$zone::pause\" Signed=\"true\" Analog=\"false\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"100\" DestValHigh=\"100\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, volume\" Comment=\"\" Address=\"\" Check=\"$zone::volume::\\v\" Signed=\"true\" Analog=\"true\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"100\" DestValHigh=\"100\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, time\" Comment=\"\" Address=\"\" Check=\"$zone::time::\\v\" Signed=\"true\" Analog=\"true\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"100\" DestValHigh=\"100\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\"/>";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, queue index\" Comment=\"\" Address=\"\" Check=\"$zone::queueIndex::\\v\" Signed=\"true\" Analog=\"true\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"100\" DestValHigh=\"100\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, play\" Comment=\"\" Address=\"\" Check=\"$zone::play\" Signed=\"true\" Analog=\"false\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"1\" DestValHigh=\"1\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, pause\" Comment=\"\" Address=\"\" Check=\"$zone::pause\" Signed=\"true\" Analog=\"false\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"1\" DestValHigh=\"1\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, volume\" Comment=\"\" Address=\"\" Check=\"$zone::volume::\\v\" Signed=\"true\" Analog=\"true\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"1\" DestValHigh=\"1\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, time\" Comment=\"\" Address=\"\" Check=\"$zone::time::\\v\" Signed=\"true\" Analog=\"true\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"1\" DestValHigh=\"1\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\"/>";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, shuffle\" Comment=\"\" Address=\"\" Check=\"$zone::shuffle::\\v\" Signed=\"true\" Analog=\"false\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"1\" DestValHigh=\"1\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\"/>";
$vi .= "<VirtualInUdpCmd Title=\"Zone $zone, queue index\" Comment=\"\" Address=\"\" Check=\"$zone::queueIndex::\\v\" Signed=\"true\" Analog=\"true\" SourceValLow=\"0\" DestValLow=\"0\" SourceValHigh=\"1\" DestValHigh=\"1\" DefVal=\"0\" MinVal=\"-10000\" MaxVal=\"10000\" />";

$vo .= "<VirtualOutCmd Title=\"Zone $zone, push title\" Comment=\"\" CmdOnMethod=\"GET\" CmdOffMethod=\"GET\" CmdOn=\"$zone::setTitle::&lt;v&gt;\" CmdOnHTTP=\"\" CmdOnPost=\"\" CmdOff=\"\" CmdOffHTTP=\"\" CmdOffPost=\"\" Analog=\"true\" Repeat=\"0\" RepeatRate=\"0\" />";
$vo .= "<VirtualOutCmd Title=\"Zone $zone, push album\" Comment=\"\" CmdOnMethod=\"GET\" CmdOffMethod=\"GET\" CmdOn=\"$zone::setAlbum::&lt;v&gt;\" CmdOnHTTP=\"\" CmdOnPost=\"\" CmdOff=\"\" CmdOffHTTP=\"\" CmdOffPost=\"\" Analog=\"true\" Repeat=\"0\" RepeatRate=\"0\" />";
Expand Down

0 comments on commit f1b96da

Please sign in to comment.