aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-05 22:19:28 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-05 22:19:28 -0700
commit616e3f804890b55c7956ca94d73cf62d36d804d5 (patch)
tree884021a4f47a295e071f58cb8ff7327bd459f389
parentbf7acf155e730b22ae17f0bb302b14c7f1076009 (diff)
downloaddsub-616e3f804890b55c7956ca94d73cf62d36d804d5.tar.gz
dsub-616e3f804890b55c7956ca94d73cf62d36d804d5.tar.bz2
dsub-616e3f804890b55c7956ca94d73cf62d36d804d5.zip
Added option to do raw video (thanks Sindre)
-rw-r--r--subsonic-android/res/menu/select_video_context.xml5
-rw-r--r--subsonic-android/res/values/arrays.xml11
-rw-r--r--subsonic-android/res/values/strings.xml10
-rw-r--r--subsonic-android/res/xml/settings.xml11
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java3
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java6
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java49
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/MusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java8
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java5
13 files changed, 86 insertions, 31 deletions
diff --git a/subsonic-android/res/menu/select_video_context.xml b/subsonic-android/res/menu/select_video_context.xml
index 7a45d34a..5926f8a5 100644
--- a/subsonic-android/res/menu/select_video_context.xml
+++ b/subsonic-android/res/menu/select_video_context.xml
@@ -11,11 +11,6 @@
<item
android:id="@+id/song_menu_play_external"
android:title="@string/common.play_external"/>
-
- <item
- android:id="@+id/song_menu_webview"
- android:title="@string/common.webview"
- />
<item
android:id="@+id/song_menu_download"
diff --git a/subsonic-android/res/values/arrays.xml b/subsonic-android/res/values/arrays.xml
index 80cc4fad..daca9b8b 100644
--- a/subsonic-android/res/values/arrays.xml
+++ b/subsonic-android/res/values/arrays.xml
@@ -137,4 +137,15 @@
<item>@string/settings.temp_loss_nothing</item>
</string-array>
+ <string-array name="videoPlayerValues">
+ <item>raw</item>
+ <item>transcode</item>
+ <item>flash</item>
+ </string-array>
+ <string-array name="videoPlayerNames">
+ <item>@string/settings.video_raw</item>
+ <item>@string/settings.video_transcode</item>
+ <item>@string/settings.video_flash</item>
+ </string-array>
+
</resources> \ No newline at end of file
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index b288e035..87905e18 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -18,9 +18,8 @@
<string name="common.name">Name</string>
<string name="common.comment">Comment</string>
<string name="common.public">Public</string>
- <string name="common.webview">Play Web View (Flash)</string>
- <string name="common.play_external">Play External Player</string>
- <string name="common.stream_external">Stream External Player</string>
+ <string name="common.play_external">Play Video</string>
+ <string name="common.stream_external">Stream Video</string>
<string name="common.confirm">Confirm</string>
<string name="button_bar.home">Home</string>
@@ -283,6 +282,11 @@
<string name="settings.chat_refresh">Chat Refresh Rate (Secs)</string>
<string name="settings.chat_enabled">Chat Enabled</string>
<string name="settings.chat_enabled_summary">Whether or not to display the chat tab. Restart app after changing.</string>
+ <string name="settings.video_title">Video</string>
+ <string name="settings.video_player">Video Player</string>
+ <string name="settings.video_raw">Raw</string>
+ <string name="settings.video_transcode">Direct Transcode</string>
+ <string name="settings.video_flash">Flash</string>
<string name="shuffle.startYear">Start Year:</string>
<string name="shuffle.endYear">End Year:</string>
diff --git a/subsonic-android/res/xml/settings.xml b/subsonic-android/res/xml/settings.xml
index 17a51621..d3618ffa 100644
--- a/subsonic-android/res/xml/settings.xml
+++ b/subsonic-android/res/xml/settings.xml
@@ -25,6 +25,17 @@
</PreferenceCategory>
+ <PreferenceCategory
+ android:title="@string/settings.video_title">
+
+ <ListPreference
+ android:title="@string/settings.video_player"
+ android:key="videoPlayer"
+ android:defaultValue="raw"
+ android:entryValues="@array/videoPlayerValues"
+ android:entries="@array/videoPlayerNames"/>
+ </PreferenceCategory>
+
<PreferenceCategory
android:title="@string/settings.network_title">
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java
index 88e487f1..e40ecab8 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -69,6 +69,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
private Preference addServerPreference;
private PreferenceCategory serversCategory;
private EditTextPreference chatRefreshRate;
+ private ListPreference videoPlayer;
private int serverCount = 3;
private SharedPreferences settings;
@@ -95,6 +96,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
addServerPreference = (Preference) findPreference(Constants.PREFERENCES_KEY_SERVER_ADD);
serversCategory = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_SERVER_KEY);
chatRefreshRate = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CHAT_REFRESH);
+ videoPlayer = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIDEO_PLAYER);
settings = Util.getPreferences(this);
serverCount = settings.getInt(Constants.PREFERENCES_KEY_SERVER_COUNT, 3);
@@ -191,6 +193,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
tempLoss.setSummary(tempLoss.getEntry());
bufferLength.setSummary(bufferLength.getText() + " seconds");
chatRefreshRate.setSummary(chatRefreshRate.getText());
+ videoPlayer.setSummary(videoPlayer.getEntry());
for (ServerSettings ss : serverSettings.values()) {
ss.update();
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 2bb04fa3..f0e370ce 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -240,11 +240,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
replaceFragment(fragment, R.id.select_album_layout);
} else if (entry.isVideo()) {
- if(entryExists(entry)) {
- playExternalPlayer(entry);
- } else {
- streamExternalPlayer(entry);
- }
+ playVideo(entry);
}
}
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 35a97e7c..84233c27 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -255,9 +255,6 @@ public class SubsonicFragment extends SherlockFragment {
case R.id.song_menu_star:
toggleStarred(entry);
break;
- case R.id.song_menu_webview:
- playWebView(entry);
- break;
case R.id.song_menu_play_external:
playExternalPlayer(entry);
break;
@@ -858,6 +855,19 @@ public class SubsonicFragment extends SherlockFragment {
.setMessage(msg)
.show();
}
+
+ protected void playVideo(MusicDirectory.Entry entry) {
+ String videoPlayerType = Util.getVideoPlayerType(context);
+ if(entryExists(entry)) {
+ playExternalPlayer(entry);
+ } else {
+ if("flash".equals(videoPlayerType)) {
+ playWebView(entry);
+ } else {
+ streamExternalPlayer(entry, "raw".equals(videoPlayerType) ? "raw" : entry.getTranscodedSuffix());
+ }
+ }
+ }
protected void playWebView(MusicDirectory.Entry entry) {
int maxBitrate = Util.getMaxVideoBitrate(context);
@@ -884,17 +894,32 @@ public class SubsonicFragment extends SherlockFragment {
}
}
protected void streamExternalPlayer(MusicDirectory.Entry entry) {
- int maxBitrate = Util.getMaxVideoBitrate(context);
+ String videoPlayerType = Util.getVideoPlayerType(context);
+ streamExternalPlayer(entry, "raw".equals(videoPlayerType) ? "raw" : entry.getTranscodedSuffix());
+ }
+ protected void streamExternalPlayer(MusicDirectory.Entry entry, String format) {
+ try {
+ int maxBitrate = Util.getMaxVideoBitrate(context);
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService(context).getVideoStreamUrl(maxBitrate, context, entry.getId())), "video/*");
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setDataAndType(Uri.parse(MusicServiceFactory.getMusicService(context).getVideoStreamUrl(format, maxBitrate, context, entry.getId())), "video/*");
+ intent.putExtra("title", entry.getTitle());
- List<ResolveInfo> intents = context.getPackageManager()
- .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
- if(intents != null && intents.size() > 0) {
- startActivity(intent);
- } else {
- Util.toast(context, R.string.download_no_streaming_player);
+ List<ResolveInfo> intents = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
+ if(intents != null && intents.size() > 0) {
+ startActivity(intent);
+ } else {
+ Util.toast(context, R.string.download_no_streaming_player);
+ }
+ } catch(Exception error) {
+ String msg;
+ if (error instanceof OfflineException || error instanceof ServerTooOldException) {
+ msg = error.getMessage();
+ } else {
+ msg = context.getResources().getString(R.string.download_no_streaming_player) + " " + error.getMessage();
+ }
+
+ Util.toast(context, msg, false);
}
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
index 3802ab3e..5bb2338f 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -229,8 +229,8 @@ public class CachedMusicService implements MusicService {
}
@Override
- public String getVideoStreamUrl(int maxBitrate, Context context, String id) {
- return musicService.getVideoStreamUrl(maxBitrate, context, id);
+ public String getVideoStreamUrl(String format, int maxBitrate, Context context, String id) throws Exception {
+ return musicService.getVideoStreamUrl(format, 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 1b60cc37..c0d0b589 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
@@ -92,7 +92,7 @@ public interface MusicService {
String getVideoUrl(int maxBitrate, Context context, String id);
- String getVideoStreamUrl(int Bitrate, Context context, String id);
+ String getVideoStreamUrl(String format, int Bitrate, Context context, String id) throws Exception;
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 e20a64de..af8f7cf7 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -448,7 +448,7 @@ public class OfflineMusicService extends RESTMusicService {
}
@Override
- public String getVideoStreamUrl(int maxBitrate, Context context, String id) {
+ public String getVideoStreamUrl(String format, int maxBitrate, Context context, String id) throws Exception {
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 dae4944c..1f283a3b 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -682,10 +682,14 @@ public class RESTMusicService implements MusicService {
}
@Override
- public String getVideoStreamUrl(int maxBitrate, Context context, String id) {
+ public String getVideoStreamUrl(String format, int maxBitrate, Context context, String id) throws Exception {
StringBuilder builder = new StringBuilder(Util.getRestUrl(context, "stream"));
builder.append("&id=").append(id);
- builder.append("&maxBitRate=").append(maxBitrate);
+ if(!"raw".equals(format)) {
+ checkServerVersion(context, "1.9", "Video streaming not supported.");
+ builder.append("&maxBitRate=").append(maxBitrate);
+ }
+ builder.append("&format=").append(format);
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 5de13e73..78ed1a41 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java
@@ -107,6 +107,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_SHUFFLE_MODE = "shuffleMode";
public static final String PREFERENCES_KEY_CHAT_REFRESH = "chatRefreshRate";
public static final String PREFERENCES_KEY_CHAT_ENABLED = "chatEnabled";
+ public static final String PREFERENCES_KEY_VIDEO_PLAYER = "videoPlayer";
public static final String CACHE_KEY_IGNORE = "ignoreArticles";
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 818a4f67..bef836b5 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -316,6 +316,11 @@ public final class Util {
return builder.toString();
}
+
+ public static String getVideoPlayerType(Context context) {
+ SharedPreferences prefs = getPreferences(context);
+ return prefs.getString(Constants.PREFERENCES_KEY_VIDEO_PLAYER, "raw");
+ }
public static SharedPreferences getPreferences(Context context) {
return context.getSharedPreferences(Constants.PREFERENCES_FILE_NAME, 0);