aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-02-26 12:07:45 -0800
committerScott Jackson <daneren2005@gmail.com>2015-02-26 12:07:45 -0800
commitdae987d86671333ba00b70c236484e5c67d00a8d (patch)
treee9bf36e42eea5cbf2c1464a68834d092db05527c /src
parenta5d0e6ed8f6e2b9cfec96c45087fe1b7b5bd2a2f (diff)
downloaddsub-dae987d86671333ba00b70c236484e5c67d00a8d.tar.gz
dsub-dae987d86671333ba00b70c236484e5c67d00a8d.tar.bz2
dsub-dae987d86671333ba00b70c236484e5c67d00a8d.zip
Use proxy for ChromeCast as well
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/ChromeCastController.java38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java
index f5def994..21ee6e13 100644
--- a/src/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/src/github/daneren2005/dsub/service/ChromeCastController.java
@@ -45,6 +45,8 @@ import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.util.compat.CastCompat;
import github.daneren2005.serverproxy.FileProxy;
+import github.daneren2005.serverproxy.ServerProxy;
+import github.daneren2005.serverproxy.WebProxy;
/**
* Created by owner on 2/9/14.
@@ -61,7 +63,7 @@ public class ChromeCastController extends RemoteController {
private boolean ignoreNextPaused = false;
private String sessionId;
- private FileProxy proxy;
+ private ServerProxy proxy;
private String rootLocation;
private RemoteMediaPlayer mediaPlayer;
private double gain = 0.5;
@@ -270,9 +272,26 @@ public class ChromeCastController extends RemoteController {
proxy.start();
}
- url = proxy.getPublicAddress(song.getId());
+ // Offline song
+ if(song.getId().indexOf(rootLocation) != -1) {
+ url = proxy.getPublicAddress(song.getId());
+ } else {
+ // Playing online song in offline mode
+ url = proxy.getPublicAddress(currentPlaying.getCompleteFile().getPath());
+ }
} else {
- if(proxy != null) {
+ // Check if we want a proxy going still
+ if(Util.isCastProxy(downloadService)) {
+ if(proxy instanceof FileProxy) {
+ proxy.stop();
+ proxy = null;
+ }
+
+ if(proxy == null) {
+ proxy = new WebProxy(downloadService);
+ proxy.start();
+ }
+ } else if(proxy != null) {
proxy.stop();
proxy = null;
}
@@ -282,6 +301,11 @@ public class ChromeCastController extends RemoteController {
} else {
url = musicService.getMusicUrl(downloadService, song, currentPlaying.getBitRate());
}
+
+ // If proxy is going, it is a WebProxy
+ if(proxy != null) {
+ url = proxy.getPublicAddress(url);
+ }
}
// Setup song/video information
@@ -296,8 +320,14 @@ public class ChromeCastController extends RemoteController {
meta.putString(MediaMetadata.KEY_ALBUM_TITLE, song.getAlbum());
String coverArt = "";
- if(proxy == null) {
+ if(proxy == null || proxy instanceof WebProxy) {
coverArt = musicService.getCoverArtUrl(downloadService, song);
+
+ // If proxy is going, it is a web proxy
+ if(proxy != null) {
+ coverArt = proxy.getPublicAddress(coverArt);
+ }
+
meta.addImage(new WebImage(Uri.parse(coverArt)));
} else {
File coverArtFile = FileUtil.getAlbumArtFile(downloadService, song);