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

Further improvement of Metadata methods #140

Merged
merged 1 commit into from
Feb 20, 2015
Merged
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 @@ -456,7 +456,7 @@ public void onValueReceived(String variable, String value, String service) {
break;
}
case "CurrentURI": {
updateCurrentURIFormatted();
updateCurrentURIFormatted(value);
break;
}
}
Expand Down Expand Up @@ -596,8 +596,15 @@ public boolean isCoordinator() {

protected void updateTrackMetaData() {

String coordinator = getCoordinator();
ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinator);
SonosMetaData currentTrack = getTrackMetadata();

if (coordinatorHandler != null && coordinatorHandler != this) {
coordinatorHandler.updateMediaInfo();
currentTrack = coordinatorHandler.getTrackMetadata();
}

if (currentTrack != null) {

String artist = null;
Expand All @@ -623,38 +630,36 @@ protected void updateTrackMetaData() {
this.onValueReceived("CurrentAlbum", (album != null) ? album : "",
"AVTransport");

if(currentTrack.getTitle().contains("x-sonosapi-stream")) {
updateMediaInfo();
}
updateMediaInfo();

}

}

protected void updateCurrentURIFormatted() {
protected void updateCurrentURIFormatted(String URI) {

String currentURI = null;
String currentURI = URI;
SonosMetaData currentTrack = null;
String coordinator = getCoordinator();
ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinator);

if (coordinatorHandler != null && coordinatorHandler != this) {
if(getCurrentURI().contains("x-rincon")) {
if(currentURI.contains("x-rincon-stream")) {
coordinatorHandler.updateMediaInfo();
}
currentURI = coordinatorHandler.getCurrentURI();
currentTrack = coordinatorHandler.getTrackMetadata();
} else {
currentURI = getCurrentURI();
// currentURI = getCurrentURI();
currentTrack = getTrackMetadata();
}

if (currentURI != null) {
String title = stateMap.get("CurrentTitle");
String resultString = stateMap.get("CurrentURIFormatted");
boolean needsUpdating = false;

if (opmlPartnerID != null && currentURI.contains("x-sonosapi-stream")) {

String stationID = StringUtils.substringBetween(currentURI,
":s", "?sid");
String previousStationID = stateMap.get("StationID");
Expand Down Expand Up @@ -706,9 +711,18 @@ protected void updateCurrentURIFormatted() {
}
}
}
} else {
}

if(currentURI.contains("x-rincon-stream")) {
if(currentTrack != null) {
resultString = stateMap.get("CurrentTitle");
needsUpdating = true;
}
}

if (currentTrack != null && !currentTrack.getTitle().contains("x-sonosapi-stream")) {

if (!currentURI.contains("x-rincon-mp3") && !currentURI.contains("x-rincon-stream") && !currentURI.contains("x-sonosapi")) {
if(currentTrack != null) {
if (currentTrack.getAlbumArtist().equals("")) {
resultString = currentTrack.getCreator() + " - "
+ currentTrack.getAlbum() + " - "
Expand All @@ -723,6 +737,7 @@ protected void updateCurrentURIFormatted() {
}
}


if(needsUpdating) {
this.onValueReceived("CurrentURIFormatted", (resultString != null) ? resultString : "",
"AVTransport");
Expand Down Expand Up @@ -1776,7 +1791,7 @@ public String getCurrentZoneName() {
}

public String getCurrentURIFormatted() {
updateCurrentURIFormatted();
updateCurrentURIFormatted(getCurrentURI());
return stateMap.get("CurrentURIFormatted");
}

Expand Down