aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-22 11:23:34 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-22 11:23:34 -0800
commitd622047a4d01122064afc177b89df522b19f12af (patch)
tree611028ca40f1f63ef4644a1ed5aacb68a8cdc7aa /src
parent2bdd4ba3db808d6b283d11d77dfd503e94ed4b1e (diff)
downloaddsub-d622047a4d01122064afc177b89df522b19f12af.tar.gz
dsub-d622047a4d01122064afc177b89df522b19f12af.tar.bz2
dsub-d622047a4d01122064afc177b89df522b19f12af.zip
#288 Only require external address for https addresses
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/ChromeCastController.java26
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java4
2 files changed, 23 insertions, 7 deletions
diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java
index 3cfde4c6..02661f14 100644
--- a/src/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/src/github/daneren2005/dsub/service/ChromeCastController.java
@@ -244,8 +244,8 @@ public class ChromeCastController extends RemoteController {
url = musicService.getMusicUrl(downloadService, song, currentPlaying.getBitRate());
}
- // Use separate profile for Chromecast so users can do ogg on phone, mp3 for CC
- url = url.replace(Constants.REST_CLIENT_ID, Constants.CHROMECAST_CLIENT_ID);
+ url = fixURLs(url);
+ Log.i(TAG, "Cast url: " + url);
}
// Setup song/video information
@@ -259,17 +259,19 @@ public class ChromeCastController extends RemoteController {
meta.putString(MediaMetadata.KEY_ALBUM_ARTIST, song.getArtist());
meta.putString(MediaMetadata.KEY_ALBUM_TITLE, song.getAlbum());
- String coverArt;
+ String coverArt = "";
if(proxy == null) {
coverArt = musicService.getCoverArtUrl(downloadService, song);
+ coverArt = fixURLs(coverArt);
meta.addImage(new WebImage(Uri.parse(coverArt)));
} else {
File coverArtFile = FileUtil.getAlbumArtFile(downloadService, song);
if(coverArtFile != null && coverArtFile.exists()) {
- coverArt = coverArtFile.getPath();
- meta.addImage(new WebImage(Uri.parse(proxy.getPublicAddress(coverArt))));
+ coverArt = proxy.getPublicAddress(coverArtFile.getPath());
+ meta.addImage(new WebImage(Uri.parse(coverArt)));
}
}
+ Log.i(TAG, "Cover art: " + coverArt);
}
String contentType;
@@ -315,6 +317,20 @@ public class ChromeCastController extends RemoteController {
}
}
+ private String fixURLs(String url) {
+ // Only change to internal when using https
+ if(url.indexOf("https") != -1) {
+ SharedPreferences prefs = Util.getPreferences(downloadService);
+ int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1);
+ String externalUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_URL + instance, null);
+ String internalUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance, null);
+ url = url.replace(internalUrl, externalUrl);
+ }
+
+ // Use separate profile for Chromecast so users can do ogg on phone, mp3 for CC
+ return url.replace(Constants.REST_CLIENT_ID, Constants.CHROMECAST_CLIENT_ID);
+ }
+
private void failedLoad() {
Util.toast(downloadService, downloadService.getResources().getString(R.string.download_failed_to_load));
downloadService.setPlayerState(PlayerState.STOPPED);
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 8ea29a41..879339cc 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -623,7 +623,7 @@ public class RESTMusicService implements MusicService {
@Override
public String getCoverArtUrl(Context context, MusicDirectory.Entry entry) throws Exception {
- StringBuilder builder = new StringBuilder(getRestUrl(context, "getCoverArt", false));
+ StringBuilder builder = new StringBuilder(getRestUrl(context, "getCoverArt"));
builder.append("&id=").append(entry.getId());
String url = rewriteUrlWithRedirect(context, builder.toString());
return url;
@@ -710,7 +710,7 @@ public class RESTMusicService implements MusicService {
@Override
public String getMusicUrl(Context context, MusicDirectory.Entry song, int maxBitrate) throws Exception {
- StringBuilder builder = new StringBuilder(getRestUrl(context, "stream", false));
+ StringBuilder builder = new StringBuilder(getRestUrl(context, "stream"));
builder.append("&id=").append(song.getId());
builder.append("&maxBitRate=").append(maxBitrate);