diff options
Diffstat (limited to 'src/github')
5 files changed, 74 insertions, 7 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); diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java index cdff990b..a2894a23 100644 --- a/src/github/daneren2005/dsub/service/DLNAController.java +++ b/src/github/daneren2005/dsub/service/DLNAController.java @@ -67,6 +67,8 @@ import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.serverproxy.FileProxy;
+import github.daneren2005.serverproxy.ServerProxy;
+import github.daneren2005.serverproxy.WebProxy;
public class DLNAController extends RemoteController {
private static final String TAG = DLNAController.class.getSimpleName();
@@ -77,7 +79,7 @@ public class DLNAController extends RemoteController { SubscriptionCallback callback;
boolean supportsSeek = false;
- private FileProxy proxy;
+ private ServerProxy proxy;
String rootLocation = "";
boolean error = false;
@@ -388,7 +390,18 @@ public class DLNAController extends RemoteController { 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;
}
@@ -398,6 +411,11 @@ public class DLNAController 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);
+ }
}
// Create metadata for entry
@@ -434,8 +452,13 @@ public class DLNAController extends RemoteController { if(song.getCoverArt() != null) {
String coverArt = null;
- 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);
+ }
} else {
File coverArtFile = FileUtil.getAlbumArtFile(downloadService, song);
if(coverArtFile != null && coverArtFile.exists()) {
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index d97fe8d0..b0bbfe31 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -152,6 +152,7 @@ public final class Constants { public static final String PREFERENCES_KEY_REPLAY_GAIN_UNTAGGED = "replayGainUntagged2"; public static final String PREFERENCES_KEY_REPLAY_GAIN_TYPE= "replayGainType"; public static final String PREFERENCES_KEY_ALBUMS_PER_FOLDER = "albumsPerFolder"; + public static final String PREFERENCES_KEY_CAST_PROXY = "castProxy"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 01588bf2..1eaf71f8 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -560,6 +560,11 @@ public final class Util { return Math.max(0, Constants.FREE_TRIAL_DAYS - daysSinceInstall); } + public static boolean isCastProxy(Context context) { + SharedPreferences prefs = getPreferences(context); + return prefs.getBoolean(Constants.PREFERENCES_KEY_CAST_PROXY, false); + } + /** * Get the contents of an <code>InputStream</code> as a <code>byte[]</code>. * <p/> diff --git a/src/github/daneren2005/dsub/view/HeaderGridView.java b/src/github/daneren2005/dsub/view/HeaderGridView.java index 8e1eddac..c8e51764 100644 --- a/src/github/daneren2005/dsub/view/HeaderGridView.java +++ b/src/github/daneren2005/dsub/view/HeaderGridView.java @@ -300,6 +300,14 @@ public class HeaderGridView extends GridView { mRowHeight = -1; } + public int getHeaderHeight(int row) { + if (row >= 0) { + return mHeaderViewInfos.get(row).view.getMeasuredHeight(); + } + + return 0; + } + public int getRowHeight() { if (mRowHeight > 0) { return mRowHeight; |