Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Sonos binding: add new channel clearqueue (#3740)
Browse files Browse the repository at this point in the history
Fix #2894

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and sjsf committed Jul 3, 2017
1 parent becd5fe commit d3a24bf
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 11 deletions.
Expand Up @@ -29,6 +29,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand All @@ -48,12 +49,12 @@
<channel id="zonegroupid" typeId="zonegroupid" />
<channel id="zonename" typeId="zonename" />
<channel id="coordinator" typeId="coordinator" />
<!-- Extended SONOS channels (PLAY5, CONNECT & CONNECT:AMP only) -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
<channel id="sleeptimer" typeId="sleeptimer" />
<channel id="currenttransporturi" typeId="currenttransporturi" />
<channel id="currenttrackuri" typeId="currenttrackuri" />
<!-- Extended SONOS channels -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
</channels>

<properties>
Expand Down
Expand Up @@ -30,6 +30,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand All @@ -49,12 +50,12 @@
<channel id="zonegroupid" typeId="zonegroupid" />
<channel id="zonename" typeId="zonename" />
<channel id="coordinator" typeId="coordinator" />
<!-- Extended SONOS channels (PLAY5, CONNECT & CONNECT:AMP only) -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
<channel id="sleeptimer" typeId="sleeptimer" />
<channel id="currenttransporturi" typeId="currenttransporturi" />
<channel id="currenttrackuri" typeId="currenttrackuri" />
<!-- Extended SONOS channels -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
</channels>

<properties>
Expand Down
Expand Up @@ -30,6 +30,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand Down
Expand Up @@ -30,6 +30,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand Down
Expand Up @@ -30,6 +30,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand All @@ -49,12 +50,12 @@
<channel id="zonegroupid" typeId="zonegroupid" />
<channel id="zonename" typeId="zonename" />
<channel id="coordinator" typeId="coordinator" />
<!-- Extended SONOS channels (PLAY5, CONNECT & CONNECT:AMP only) -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
<channel id="sleeptimer" typeId="sleeptimer" />
<channel id="currenttransporturi" typeId="currenttransporturi" />
<channel id="currenttrackuri" typeId="currenttrackuri" />
<!-- Extended SONOS channels -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
</channels>

<properties>
Expand Down
Expand Up @@ -29,6 +29,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand All @@ -48,11 +49,12 @@
<channel id="zonegroupid" typeId="zonegroupid" />
<channel id="zonename" typeId="zonename" />
<channel id="coordinator" typeId="coordinator" />
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
<channel id="sleeptimer" typeId="sleeptimer" />
<channel id="currenttransporturi" typeId="currenttransporturi" />
<channel id="currenttrackuri" typeId="currenttrackuri" />
<!-- Extended SONOS channels -->
<channel id="linein" typeId="linein" />
<channel id="playlinein" typeId="playlinein" />
</channels>

<properties>
Expand Down
Expand Up @@ -30,6 +30,7 @@
<channel id="notificationsound" typeId="notificationsound" />
<channel id="notificationvolume" typeId="notificationvolume" />
<channel id="playlist" typeId="playlist" />
<channel id="clearqueue" typeId="clearqueue" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
Expand Down
Expand Up @@ -114,6 +114,12 @@
<description>Play the given playlist. The playlist has to predefined in the Sonos Controller app</description>
</channel-type>

<channel-type id="clearqueue" advanced="true">
<item-type>Switch</item-type>
<label>Clear Queue</label>
<description>Suppress all songs from the current queue</description>
</channel-type>

<channel-type id="playqueue" advanced="true">
<item-type>Switch</item-type>
<label>Play Queue</label>
Expand Down
Expand Up @@ -68,6 +68,7 @@ public class SonosBindingConstants {
public final static String NOTIFICATIONVOLUME = "notificationvolume";
public final static String PLAYLINEIN = "playlinein";
public final static String PLAYLIST = "playlist";
public final static String CLEARQUEUE = "clearqueue";
public final static String PLAYQUEUE = "playqueue";
public final static String PLAYTRACK = "playtrack";
public final static String PLAYURI = "playuri";
Expand Down
Expand Up @@ -281,6 +281,9 @@ public void handleCommand(ChannelUID channelUID, Command command) {
case PLAYLIST:
playPlayList(command);
break;
case CLEARQUEUE:
clearQueue();
break;
case PLAYQUEUE:
playQueue();
break;
Expand Down Expand Up @@ -2443,6 +2446,17 @@ public void removeRangeOfTracksFromQueue(Command command) {
}
}

public void clearQueue() {
try {
ZonePlayerHandler coordinator = getCoordinatorHandler();

coordinator.removeAllTracksFromQueue();

} catch (IllegalStateException e) {
logger.warn("Cannot clear queue ({})", e.getMessage());
}
}

public void playQueue() {
try {
ZonePlayerHandler coordinator = getCoordinatorHandler();
Expand Down

0 comments on commit d3a24bf

Please sign in to comment.