From 195f84602029f3e9b56461cea29bb94d7b334ba9 Mon Sep 17 00:00:00 2001 From: Karel Goderis Date: Fri, 20 Feb 2015 23:03:56 +0100 Subject: [PATCH] Implement playQueue functionality Signed-off-by: Karel Goderis --- .../ESH-INF/thing/thing-types.xml | 8 ++++++++ .../binding/sonos/SonosBindingConstants.java | 1 + .../binding/sonos/handler/ZonePlayerHandler.java | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml b/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml index b14c669fa130e..0748a60ed1df4 100644 --- a/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml +++ b/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml @@ -25,6 +25,7 @@ + @@ -150,6 +151,13 @@ Play the given playlist. The playlist has to predefined in the Sonos Controller app + + Switch + + Play the songs from the current queue + + + String diff --git a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java index ad1338d8c4b70..b1fc829ec1850 100644 --- a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java +++ b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java @@ -39,6 +39,7 @@ public class SonosBindingConstants { public final static String MUTE = "mute"; public final static String PLAYLINEIN = "playlinein"; public final static String PLAYLIST = "playlist"; + public final static String PLAYQUEUE = "playqueue"; public final static String PLAYURI = "playuri"; public final static String PUBLICADDRESS = "publicaddress"; public final static String RADIO = "radio"; diff --git a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java index eb4015551362d..7e546041e8ada 100644 --- a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java +++ b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java @@ -233,6 +233,9 @@ public void handleCommand(ChannelUID channelUID, Command command) { case PLAYLIST: playPlayList(command); break; + case PLAYQUEUE: + playQueue(command); + break; case PLAYURI: playURI(command); break; @@ -1638,6 +1641,19 @@ public void playURI(Command command) { } } + + public void playQueue(Command command) { + ZonePlayerHandler coordinator = getHandlerByName(getCoordinator()); + + // set the current playlist to our new queue + coordinator.setCurrentURI("x-rincon-queue:" + getUDN() + "#0", ""); + + // take the system off mute + coordinator.setMute(OnOffType.OFF); + + // start jammin' + coordinator.play(); + } public void setLed(Command command) { if (command != null) {