diff options
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | res/xml/settings.xml | 10 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/ChromeCastController.java | 38 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DLNAController.java | 29 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Constants.java | 1 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Util.java | 5 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/view/HeaderGridView.java | 8 |
7 files changed, 87 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index eed2f1c7..5940f710 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -441,6 +441,9 @@ <string name="settings.replay_gain_type.track">Track tags</string>
<string name="settings.replay_gain_bump">Replay Gain Pre-amp</string>
<string name="settings.replay_gain_untagged">Songs without Replay Gain</string>
+ <string name="settings.casting">Casting</string>
+ <string name="settings.casting_proxy">Use device proxy</string>
+ <string name="settings.casting_proxy_summary">Stream everything through the device as a proxy. This gets around issues such as using self-signed certificates.</string>
<string name="shuffle.title">Shuffle By</string>
<string name="shuffle.startYear">Start Year:</string>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 8b53a6fa..91b9ea1a 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -361,6 +361,16 @@ </PreferenceCategory> <PreferenceCategory + android:title="@string/settings.casting"> + + <CheckBoxPreference + android:title="@string/settings.casting_proxy" + android:summary="@string/settings.casting_proxy_summary" + android:key="castProxy" + android:defaultValue="false"/> + </PreferenceCategory> + + <PreferenceCategory android:title="@string/settings.replay_gain"> <CheckBoxPreference 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; |