[Android] Update util method to open media
Geoffrey Métais
git at videolan.org
Mon Feb 9 11:30:49 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 4 12:37:44 2015 +0100| [570ebd15de423e35d3f64ce580985ba8412ebd85] | committer: Geoffrey Métais
Update util method to open media
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=570ebd15de423e35d3f64ce580985ba8412ebd85
---
vlc-android/src/org/videolan/vlc/util/Strings.java | 9 ++++++
.../tv/src/org/videolan/vlc/gui/tv/TvUtil.java | 32 ++++++++++++++------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/Strings.java b/vlc-android/src/org/videolan/vlc/util/Strings.java
index 473780d..f8460fd 100644
--- a/vlc-android/src/org/videolan/vlc/util/Strings.java
+++ b/vlc-android/src/org/videolan/vlc/util/Strings.java
@@ -20,6 +20,8 @@
package org.videolan.vlc.util;
+import org.videolan.vlc.MediaWrapper;
+
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
@@ -121,4 +123,11 @@ public class Strings {
else
return path;
}
+
+ public static String getMediaTitle(MediaWrapper mediaWrapper){
+ String title = mediaWrapper.getTitle();
+ if (title == null)
+ title = getName(mediaWrapper.getLocation());
+ return title;
+ }
}
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/TvUtil.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/TvUtil.java
index cfe323c..e69de06 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/TvUtil.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/TvUtil.java
@@ -20,7 +20,10 @@
package org.videolan.vlc.gui.tv;
import org.videolan.vlc.MediaWrapper;
+import org.videolan.vlc.gui.network.NetworkFragment;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
+import org.videolan.vlc.interfaces.IVideoBrowser;
+import org.videolan.vlc.util.Strings;
import android.app.Activity;
import android.content.Intent;
@@ -30,16 +33,25 @@ import android.support.v17.leanback.widget.Row;
public class TvUtil {
- public static void openMedia(Activity activity, MediaWrapper MediaWrapper, Row row){
- if (MediaWrapper.getType() == MediaWrapper.TYPE_VIDEO){
- VideoPlayerActivity.start(activity, MediaWrapper.getLocation(), false);
- } else if (MediaWrapper.getType() == MediaWrapper.TYPE_AUDIO){
- Intent intent = new Intent(activity,
- DetailsActivity.class);
- // pass the item information
- intent.putExtra("item", (Parcelable)new MediaItemDetails(MediaWrapper.getTitle(), MediaWrapper.getArtist(), MediaWrapper.getAlbum(), MediaWrapper.getLocation()));
- activity.startActivity(intent);
- } else if (MediaWrapper.getType() == MediaWrapper.TYPE_GROUP){
+ public static void openMedia(Activity activity, Object item , Row row){
+ if (item instanceof MediaWrapper) {
+ MediaWrapper mediaWrapper = (MediaWrapper) item;
+ if (mediaWrapper.getType() == MediaWrapper.TYPE_VIDEO) {
+ String title = mediaWrapper.getTitle();
+ VideoPlayerActivity.start(activity, mediaWrapper.getLocation(), Strings.getMediaTitle(mediaWrapper));
+ } else if (mediaWrapper.getType() == MediaWrapper.TYPE_AUDIO) {
+ Intent intent = new Intent(activity,
+ DetailsActivity.class);
+ // pass the item information
+ intent.putExtra("item", (Parcelable) new MediaItemDetails(mediaWrapper.getTitle(), mediaWrapper.getArtist(), mediaWrapper.getAlbum(), mediaWrapper.getLocation()));
+ activity.startActivity(intent);
+ } else if (mediaWrapper.getType() == MediaWrapper.TYPE_DIR){
+ Intent intent = new Intent(activity, VerticalGridActivity.class);
+ intent.putExtra("id", IVideoBrowser.HEADER_NETWORK);
+ intent.putExtra(NetworkFragment.KEY_MRL, mediaWrapper.getLocation());
+ activity.startActivity(intent);
+ }
+ } else if (item instanceof CardPresenter.SimpleCard){
Intent intent = new Intent(activity, VerticalGridActivity.class);
intent.putExtra("id", row.getId());
activity.startActivity(intent);
More information about the Android
mailing list