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

Commit

Permalink
Sonos binding: handle Google Play Music radio (#3940)
Browse files Browse the repository at this point in the history
* Sonos binding: handle Google Play Music radio
* Sonos binding: define unit for configuration settings

Fix #3937

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and maggu2810 committed Aug 9, 2017
1 parent 67bffae commit fa773e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Expand Up @@ -12,10 +12,9 @@
<parameter name="notificationTimeout" type="integer" unit="s">
<label>Notification Timeout</label>
<description>Specifies the amount of time in seconds for which the notification sound will be played</description>
<unitLabel>second</unitLabel>
<default>20</default>
</parameter>
<parameter name="refresh" type="integer">
<parameter name="refresh" type="integer" unit="s">
<label>Refresh interval</label>
<description>Specifies the refresh interval in seconds</description>
<default>60</default>
Expand Down
Expand Up @@ -85,6 +85,7 @@ public class ZonePlayerHandler extends BaseThingHandler implements UpnpIOPartici
private final static String QUEUE_URI = "x-rincon-queue:";
private final static String GROUP_URI = "x-rincon:";
private final static String STREAM_URI = "x-sonosapi-stream:";
private final static String RADIO_URI = "x-sonosapi-radio:";
private final static String FILE_URI = "x-file-cifs:";
private final static String SPDIF = ":spdif";

Expand Down Expand Up @@ -1016,7 +1017,9 @@ else if (isPlayingLineIn(currentURI)) {
}
}

else if (!currentURI.contains("x-rincon-mp3") && !currentURI.contains("x-sonosapi")) {
else if (isPlayingRadio(currentURI)
|| (!currentURI.contains("x-rincon-mp3") && !currentURI.contains("x-sonosapi"))) {
// isPlayingRadio(currentURI) is true for Google Play Music radio or Apple Music radio
if (currentTrack != null) {
artist = !currentTrack.getAlbumArtist().isEmpty() ? currentTrack.getAlbumArtist()
: currentTrack.getCreator();
Expand Down Expand Up @@ -1284,8 +1287,8 @@ protected void saveState() {

if (currentURI != null) {

if (isPlayingStream(currentURI)) {
// we are streaming music
if (isPlayingStream(currentURI) || isPlayingRadio(currentURI)) {
// we are streaming music, like tune-in radio or Google Play Music radio
SonosMetaData track = getTrackMetadata();
SonosMetaData current = getCurrentURIMetadata();
if (track != null && current != null) {
Expand Down Expand Up @@ -2236,7 +2239,7 @@ public void playNotificationSoundURI(Command notificationURL) {

String currentURI = coordinator.getCurrentURI();

if (isPlayingStream(currentURI)) {
if (isPlayingStream(currentURI) || isPlayingRadio(currentURI)) {
handleRadioStream(currentURI, notificationURL, coordinator);
} else if (isPlayingLineIn(currentURI)) {
handleLineIn(currentURI, notificationURL, coordinator);
Expand Down Expand Up @@ -2273,6 +2276,13 @@ private boolean isPlayingStream(String currentURI) {
return currentURI.contains(STREAM_URI);
}

private boolean isPlayingRadio(String currentURI) {
if (currentURI == null) {
return false;
}
return currentURI.contains(RADIO_URI);
}

private boolean isPlayingLineIn(String currentURI) {
if (currentURI == null) {
return false;
Expand Down

0 comments on commit fa773e8

Please sign in to comment.