diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-01-09 18:56:20 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-01-09 18:56:20 -0800 |
commit | f29e410bf704029afd0f6927fdb530f72e038c96 (patch) | |
tree | 58e8585949e58037b86a8ca86a9c02287e782117 /subsonic-android | |
parent | b1a98f5f081cd02018f78783e1979d60a7468a02 (diff) | |
download | dsub-f29e410bf704029afd0f6927fdb530f72e038c96.tar.gz dsub-f29e410bf704029afd0f6927fdb530f72e038c96.tar.bz2 dsub-f29e410bf704029afd0f6927fdb530f72e038c96.zip |
Added setting for video stream bitrate
Diffstat (limited to 'subsonic-android')
12 files changed, 97 insertions, 17 deletions
diff --git a/subsonic-android/res/values/arrays.xml b/subsonic-android/res/values/arrays.xml index 493239e9..75ad2bea 100644 --- a/subsonic-android/res/values/arrays.xml +++ b/subsonic-android/res/values/arrays.xml @@ -77,6 +77,34 @@ <item>@string/settings.max_bitrate_unlimited</item> </string-array> + <string-array name="maxVideoBitrateValues"> + <item>200</item> + <item>300</item> + <item>400</item> + <item>500</item> + <item>700</item> + <item>1000</item> + <item>1500</item> + <item>2000</item> + <item>3000</item> + <item>5000</item> + <item>0</item> + </string-array> + + <string-array name="maxVideoBitrateNames"> + <item>@string/settings.max_video_bitrate_200</item> + <item>@string/settings.max_video_bitrate_300</item> + <item>@string/settings.max_video_bitrate_400</item> + <item>@string/settings.max_video_bitrate_500</item> + <item>@string/settings.max_video_bitrate_700</item> + <item>@string/settings.max_video_bitrate_1000</item> + <item>@string/settings.max_video_bitrate_1500</item> + <item>@string/settings.max_video_bitrate_2000</item> + <item>@string/settings.max_video_bitrate_3000</item> + <item>@string/settings.max_video_bitrate_5000</item> + <item>@string/settings.max_bitrate_unlimited</item> + </string-array> + <string-array name="networkTimeoutValues"> <item>10000</item> <item>15000</item> diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index fb18d16c..9c9ac4b8 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -196,8 +196,8 @@ <string name="settings.theme_dark_fullscreen">Dark Fullscreen</string>
<string name="settings.theme_holo_fullscreen">Holo Fullscreen</string>
<string name="settings.network_title">Network</string>
- <string name="settings.max_bitrate_wifi">Max bitrate - Wi-Fi</string>
- <string name="settings.max_bitrate_mobile">Max bitrate - Mobile</string>
+ <string name="settings.max_bitrate_wifi">Max Audio bitrate - Wi-Fi</string>
+ <string name="settings.max_bitrate_mobile">Max Audio bitrate - Mobile</string>
<string name="settings.max_bitrate_32">32 Kbps</string>
<string name="settings.max_bitrate_64">64 Kbps</string>
<string name="settings.max_bitrate_80">80 Kbps</string>
@@ -208,6 +208,18 @@ <string name="settings.max_bitrate_192">192 Kbps</string>
<string name="settings.max_bitrate_256">256 Kbps</string>
<string name="settings.max_bitrate_320">320 Kbps</string>
+ <string name="settings.max_video_bitrate_wifi">Max Video bitrate - Wi-Fi</string>
+ <string name="settings.max_video_bitrate_mobile">Max Video bitrate - Mobile</string>
+ <string name="settings.max_video_bitrate_200">200 Kbps</string>
+ <string name="settings.max_video_bitrate_300">300 Kbps</string>
+ <string name="settings.max_video_bitrate_400">400 Kbps</string>
+ <string name="settings.max_video_bitrate_500">500 Kbps</string>
+ <string name="settings.max_video_bitrate_700">700 Kbps</string>
+ <string name="settings.max_video_bitrate_1000">1000 Kbps</string>
+ <string name="settings.max_video_bitrate_1500">1500 Kbps</string>
+ <string name="settings.max_video_bitrate_2000">2000 Kbps</string>
+ <string name="settings.max_video_bitrate_3000">3000 Kbps</string>
+ <string name="settings.max_video_bitrate_5000">5000 Kbps</string>
<string name="settings.max_bitrate_unlimited">Unlimited</string>
<string name="settings.wifi_required_title">Wi-Fi streaming only</string>
<string name="settings.wifi_required_summary">Only stream media if connected to Wi-Fi</string>
diff --git a/subsonic-android/res/xml/settings.xml b/subsonic-android/res/xml/settings.xml index ebb19e03..d6570e85 100644 --- a/subsonic-android/res/xml/settings.xml +++ b/subsonic-android/res/xml/settings.xml @@ -131,6 +131,20 @@ android:defaultValue="0" android:entryValues="@array/maxBitrateValues" android:entries="@array/maxBitrateNames"/> + + <ListPreference + android:title="@string/settings.max_video_bitrate_wifi" + android:key="maxVideoBitrateWifi" + android:defaultValue="0" + android:entryValues="@array/maxVideoBitrateValues" + android:entries="@array/maxVideoBitrateNames"/> + + <ListPreference + android:title="@string/settings.max_video_bitrate_mobile" + android:key="maxVideoBitrateMobile" + android:defaultValue="0" + android:entryValues="@array/maxVideoBitrateValues" + android:entries="@array/maxVideoBitrateNames"/> <CheckBoxPreference android:title="@string/settings.wifi_required_title" diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java index 165054d2..0bcaa28a 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java @@ -377,8 +377,10 @@ public class SearchActivity extends SubsonicTabActivity { } private void onVideoSelected(MusicDirectory.Entry entry) { + int maxBitrate = Util.getMaxVideoBitrate(this); + Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(this, entry.getId()))); + intent.setData(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(maxBitrate, this, entry.getId()))); startActivity(intent); } diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 6362f039..9ddaecf3 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -553,8 +553,10 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } private void playWebView(MusicDirectory.Entry entry) { + int maxBitrate = Util.getMaxVideoBitrate(this); + Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(this, entry.getId()))); + intent.setData(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(maxBitrate, this, entry.getId()))); startActivity(intent); } @@ -575,8 +577,10 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } } private void streamExternalPlayer(MusicDirectory.Entry entry) { + int maxBitrate = Util.getMaxVideoBitrate(this); + Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoStreamUrl(this, entry.getId())), "video/*"); + intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoStreamUrl(maxBitrate, this, entry.getId())), "video/*"); List<ResolveInfo> intents = getPackageManager() .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java index 97c4c44d..fa57fc53 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -52,6 +52,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private ListPreference theme; private ListPreference maxBitrateWifi; private ListPreference maxBitrateMobile; + private ListPreference maxVideoBitrateWifi; + private ListPreference maxVideoBitrateMobile; private ListPreference networkTimeout; private EditTextPreference cacheSize; private EditTextPreference cacheLocation; @@ -67,6 +69,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME); maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI); maxBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE); + maxVideoBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_VIDEO_BITRATE_WIFI); + maxVideoBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_VIDEO_BITRATE_MOBILE); networkTimeout = (ListPreference) findPreference(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT); cacheSize = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE); cacheLocation = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION); @@ -155,6 +159,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer theme.setSummary(theme.getEntry()); maxBitrateWifi.setSummary(maxBitrateWifi.getEntry()); maxBitrateMobile.setSummary(maxBitrateMobile.getEntry()); + maxVideoBitrateWifi.setSummary(maxVideoBitrateWifi.getEntry()); + maxVideoBitrateMobile.setSummary(maxVideoBitrateMobile.getEntry()); networkTimeout.setSummary(networkTimeout.getEntry()); cacheSize.setSummary(cacheSize.getText()); cacheLocation.setSummary(cacheLocation.getText()); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java index fe0a3f19..4028b029 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -216,13 +216,13 @@ public class CachedMusicService implements MusicService { } @Override - public String getVideoUrl(Context context, String id) { - return musicService.getVideoUrl(context, id); + public String getVideoUrl(int maxBitrate, Context context, String id) { + return musicService.getVideoUrl(maxBitrate, context, id); } @Override - public String getVideoStreamUrl(Context context, String id) { - return musicService.getVideoStreamUrl(context, id); + public String getVideoStreamUrl(int maxBitrate, Context context, String id) { + return musicService.getVideoStreamUrl(maxBitrate, context, id); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java index 98951853..702b4aa7 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java @@ -85,9 +85,9 @@ public interface MusicService { Version getLatestVersion(Context context, ProgressListener progressListener) throws Exception; - String getVideoUrl(Context context, String id); + String getVideoUrl(int maxBitrate, Context context, String id); - String getVideoStreamUrl(Context context, String id); + String getVideoStreamUrl(int Bitrate, Context context, String id); JukeboxStatus updateJukeboxPlaylist(List<String> ids, Context context, ProgressListener progressListener) throws Exception; diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 33b406cb..21bce39c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -335,12 +335,12 @@ public class OfflineMusicService extends RESTMusicService { } @Override - public String getVideoUrl(Context context, String id) { + public String getVideoUrl(int maxBitrate, Context context, String id) { return null; } @Override - public String getVideoStreamUrl(Context context, String id) { + public String getVideoStreamUrl(int maxBitrate, Context context, String id) { return null; } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index 47f92bde..6a33e60d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -637,10 +637,10 @@ public class RESTMusicService implements MusicService { } @Override - public String getVideoUrl(Context context, String id) { + public String getVideoUrl(int maxBitrate, Context context, String id) { StringBuilder builder = new StringBuilder(Util.getRestUrl(context, "videoPlayer")); builder.append("&id=").append(id); - builder.append("&maxBitRate=500"); + builder.append("&maxBitRate=").append(maxBitrate); builder.append("&autoplay=true"); String url = rewriteUrlWithRedirect(context, builder.toString()); @@ -649,10 +649,10 @@ public class RESTMusicService implements MusicService { } @Override - public String getVideoStreamUrl(Context context, String id) { + public String getVideoStreamUrl(int maxBitrate, Context context, String id) { StringBuilder builder = new StringBuilder(Util.getRestUrl(context, "stream")); builder.append("&id=").append(id); - builder.append("&maxBitRate=500"); + builder.append("&maxBitRate=").append(maxBitrate); String url = rewriteUrlWithRedirect(context, builder.toString()); Log.i(TAG, "Using video URL: " + url); diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index 4d48b6d4..bf344fe6 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -65,6 +65,8 @@ public final class Constants { public static final String PREFERENCES_KEY_THEME = "theme"; public static final String PREFERENCES_KEY_MAX_BITRATE_WIFI = "maxBitrateWifi"; public static final String PREFERENCES_KEY_MAX_BITRATE_MOBILE = "maxBitrateMobile"; + public static final String PREFERENCES_KEY_MAX_VIDEO_BITRATE_WIFI = "maxVideoBitrateWifi"; + public static final String PREFERENCES_KEY_MAX_VIDEO_BITRATE_MOBILE = "maxVideoBitrateMobile"; public static final String PREFERENCES_KEY_NETWORK_TIMEOUT = "networkTimeout"; public static final String PREFERENCES_KEY_CACHE_SIZE = "cacheSize"; public static final String PREFERENCES_KEY_CACHE_LOCATION = "cacheLocation"; diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 09aa570c..bd10f1b7 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -209,6 +209,18 @@ public final class Util { SharedPreferences prefs = getPreferences(context); return Integer.parseInt(prefs.getString(wifi ? Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI : Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE, "0")); } + + public static int getMaxVideoBitrate(Context context) { + ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo networkInfo = manager.getActiveNetworkInfo(); + if (networkInfo == null) { + return 0; + } + + boolean wifi = networkInfo.getType() == ConnectivityManager.TYPE_WIFI; + SharedPreferences prefs = getPreferences(context); + return Integer.parseInt(prefs.getString(wifi ? Constants.PREFERENCES_KEY_MAX_VIDEO_BITRATE_WIFI : Constants.PREFERENCES_KEY_MAX_VIDEO_BITRATE_MOBILE, "0")); + } public static int getPreloadCount(Context context) { SharedPreferences prefs = getPreferences(context); |