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

Sonos binding: add new channel clearqueue #3740

Merged
merged 1 commit into from Jul 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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