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

Sonos binding: handle Google Play Music radio #3940

Merged
merged 2 commits into from Aug 9, 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 @@ -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 @@ -987,7 +988,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 @@ -1253,8 +1256,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 @@ -2205,7 +2208,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 @@ -2242,6 +2245,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