aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android/src')
-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
9 files changed, 57 insertions, 23 deletions
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);