Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonos : implementation of new commands #141

Merged
merged 2 commits into from
Feb 21, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<channel id="mute" typeId="mute" />
<channel id="playlinein" typeId="playlinein" />
<channel id="playlist" typeId="playlist" />
<channel id="playqueue" typeId="playqueue" />
<channel id="playtrack" typeId="playtrack" />
<channel id="playuri" typeId="playuri" />
<channel id="publicaddress" typeId="publicaddress" />
<channel id="radio" typeId="radio" />
Expand Down Expand Up @@ -150,6 +152,18 @@
<description>Play the given playlist. The playlist has to predefined in the Sonos Controller app</description>
</channel-type>

<channel-type id="playqueue" advanced="true">
<item-type>Switch</item-type>
<label>Play Queue</label>
<description>Play the songs from the current queue</description>
</channel-type>

<channel-type id="playtrack" advanced="true">
<item-type>Number</item-type>
<label>Play Track</label>
<description>Play the given track number from the current queue</description>
</channel-type>

<channel-type id="playuri" advanced="true">
<item-type>String</item-type>
<label>Play URI</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ 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 PLAYTRACK = "playtrack";
public final static String PLAYURI = "playuri";
public final static String PUBLICADDRESS = "publicaddress";
public final static String RADIO = "radio";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ public void handleCommand(ChannelUID channelUID, Command command) {
case PLAYLIST:
playPlayList(command);
break;
case PLAYQUEUE:
playQueue(command);
break;
case PLAYTRACK:
playTrack(command);
break;
case PLAYURI:
playURI(command);
break;
Expand Down Expand Up @@ -653,7 +659,7 @@ protected void updateCurrentURIFormatted(String URI) {
// currentURI = getCurrentURI();
currentTrack = getTrackMetadata();
}

if (currentURI != null) {
String title = stateMap.get("CurrentTitle");
String resultString = stateMap.get("CurrentURIFormatted");
Expand Down Expand Up @@ -1204,6 +1210,10 @@ public void setPosition(String relTime) {
public void setPositionTrack(long tracknr) {
seek("TRACK_NR", Long.toString(tracknr));
}

public void setPositionTrack(String tracknr) {
seek("TRACK_NR", tracknr);
}

protected void seek(String unit, String target) {
if (unit != null && target != null) {
Expand Down Expand Up @@ -1639,6 +1649,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) {
if (command instanceof OnOffType
Expand Down Expand Up @@ -1723,6 +1746,25 @@ public void playRadio(Command command) {

}

public void playTrack(Command command) {

if(command != null && command instanceof DecimalType) {
ZonePlayerHandler coordinator = getHandlerByName(getCoordinator());

String trackNumber = command.toString();

// seek the track - warning, we do not check if the tracknumber falls in the boundary of the queue
setPositionTrack(trackNumber);

// take the system off mute
coordinator.setMute(OnOffType.OFF);

// start jammin'
coordinator.play();
}

}

public void playPlayList(Command command) {
List<SonosEntry> playlists = getPlayLists();
SonosEntry theEntry = null;
Expand Down