[Android] [PATCH] Use MRLs and libvlc_media_new_location everywhere
Edward Wang
edward.c.wang at compdigitec.com
Tue Mar 13 05:03:57 CET 2012
---
Updated with all issues addressed
vlc-android/jni/libvlcjni.c | 18 ++--
vlc-android/src/org/videolan/vlc/AudioService.java | 14 ++--
.../src/org/videolan/vlc/DatabaseManager.java | 51 ++++++++-----
vlc-android/src/org/videolan/vlc/LibVLC.java | 6 +-
vlc-android/src/org/videolan/vlc/Media.java | 81 ++++++++++++++------
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 23 +++---
.../src/org/videolan/vlc/ThumbnailerManager.java | 2 +-
vlc-android/src/org/videolan/vlc/Util.java | 30 +++++++
.../src/org/videolan/vlc/gui/SearchActivity.java | 8 +-
.../vlc/gui/audio/AudioBrowserActivity.java | 2 +-
.../videolan/vlc/gui/audio/AudioListActivity.java | 4 +-
.../vlc/gui/audio/AudioPlaylistAdapter.java | 2 +-
.../vlc/gui/audio/AudioSongsListAdapter.java | 4 +-
.../videolan/vlc/gui/video/MediaInfoActivity.java | 6 +-
.../videolan/vlc/gui/video/VideoListActivity.java | 2 +-
.../videolan/vlc/gui/video/VideoListAdapter.java | 4 +-
.../vlc/gui/video/VideoPlayerActivity.java | 2 +-
17 files changed, 168 insertions(+), 91 deletions(-)
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index ee8bf31..4b84f5e 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -34,13 +34,13 @@
#define LOG_TAG "VLC/JNI/main"
#include "log.h"
-libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring filePath)
+libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring fileLocation)
{
libvlc_instance_t *libvlc = (libvlc_instance_t*)instance;
jboolean isCopy;
- const char *psz_path = (*env)->GetStringUTFChars(env, filePath, &isCopy);
- libvlc_media_t *p_md = libvlc_media_new_path(libvlc, psz_path);
- (*env)->ReleaseStringUTFChars(env, filePath, psz_path);
+ const char *psz_location = (*env)->GetStringUTFChars(env, fileLocation, &isCopy);
+ libvlc_media_t *p_md = libvlc_media_new_location(libvlc, psz_location);
+ (*env)->ReleaseStringUTFChars(env, fileLocation, psz_location);
if (!p_md)
return NULL;
@@ -444,10 +444,10 @@ void Java_org_videolan_vlc_LibVLC_readMedia(JNIEnv *env, jobject thiz,
}
jboolean Java_org_videolan_vlc_LibVLC_hasVideoTrack(JNIEnv *env, jobject thiz,
- jint i_instance, jstring filePath)
+ jint i_instance, jstring fileLocation)
{
/* Create a new item and assign it to the media player. */
- libvlc_media_t *p_m = new_media(i_instance, env, thiz, filePath);
+ libvlc_media_t *p_m = new_media(i_instance, env, thiz, fileLocation);
if (p_m == NULL)
{
LOGE("Couldn't create the media!");
@@ -558,8 +558,8 @@ static void length_changed_callback(const libvlc_event_t *ev, void *data)
pthread_mutex_unlock(&monitor->doneMutex);
}
-jlong Java_org_videolan_vlc_LibVLC_getLengthFromFile(JNIEnv *env, jobject thiz,
- jint i_instance, jstring filePath)
+jlong Java_org_videolan_vlc_LibVLC_getLengthFromLocation(JNIEnv *env, jobject thiz,
+ jint i_instance, jstring fileLocation)
{
jlong length = 0;
struct length_change_monitor *monitor;
@@ -573,7 +573,7 @@ jlong Java_org_videolan_vlc_LibVLC_getLengthFromFile(JNIEnv *env, jobject thiz,
monitor->length_changed = false;
/* Create a new item and assign it to the media player. */
- libvlc_media_t *m = new_media(i_instance, env, thiz, filePath);
+ libvlc_media_t *m = new_media(i_instance, env, thiz, fileLocation);
if (m == NULL)
{
LOGE("Couldn't create the media to play!");
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 233c276..f35aa8d 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -292,7 +292,7 @@ public class AudioService extends Service {
return;
}
}
- mLibVLC.readMedia(mCurrentMedia.getPath());
+ mLibVLC.readMedia(mCurrentMedia.getLocation());
mHandler.sendEmptyMessage(SHOW_PROGRESS);
showNotification();
updateWidget(this);
@@ -306,7 +306,7 @@ public class AudioService extends Service {
mCurrentMedia = mMediaList.get(index - 1);
else
return;
- mLibVLC.readMedia(mCurrentMedia.getPath());
+ mLibVLC.readMedia(mCurrentMedia.getLocation());
mHandler.sendEmptyMessage(SHOW_PROGRESS);
showNotification();
updateWidget(this);
@@ -344,7 +344,7 @@ public class AudioService extends Service {
if (b != null)
return b;
}
- File f = new File(mCurrentMedia.getPath());
+ File f = new File(mCurrentMedia.getLocation());
for (File s : f.getParentFile().listFiles()) {
if (s.getAbsolutePath().endsWith("png") ||
s.getAbsolutePath().endsWith("jpg"))
@@ -359,7 +359,7 @@ public class AudioService extends Service {
@Override
public String getCurrentMediaPath() throws RemoteException {
- return mCurrentMedia.getPath();
+ return mCurrentMedia.getLocation();
}
@Override
@@ -478,7 +478,7 @@ public class AudioService extends Service {
}
if (mCurrentMedia != null)
- mLibVLC.readMedia(mCurrentMedia.getPath());
+ mLibVLC.readMedia(mCurrentMedia.getLocation());
showNotification();
}
@@ -501,14 +501,14 @@ public class AudioService extends Service {
ArrayList<String> medias = new ArrayList<String>();
for (int i = 0; i < mMediaList.size(); i++) {
Media item = mMediaList.get(i);
- medias.add(item.getPath());
+ medias.add(item.getLocation());
}
return medias;
}
public String getItem() {
return mCurrentMedia != null
- ? mCurrentMedia.getPath()
+ ? mCurrentMedia.getLocation()
: null;
}
diff --git a/vlc-android/src/org/videolan/vlc/DatabaseManager.java b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
index bfc4358..e46ea2a 100644
--- a/vlc-android/src/org/videolan/vlc/DatabaseManager.java
+++ b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
@@ -22,6 +22,8 @@ package org.videolan.vlc;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -51,7 +53,7 @@ public class DatabaseManager {
private final String DIR_ROW_PATH = "path";
private final String MEDIA_TABLE_NAME = "media_table";
- private final String MEDIA_PATH = "path";
+ private final String MEDIA_LOCATION = "location";
private final String MEDIA_TIME = "time";
private final String MEDIA_LENGTH = "length";
private final String MEDIA_TYPE = "type";
@@ -115,7 +117,7 @@ public class DatabaseManager {
String createMediaTabelQuery = "CREATE TABLE IF NOT EXISTS "
+ MEDIA_TABLE_NAME + " ("
- + MEDIA_PATH + " TEXT PRIMARY KEY NOT NULL, "
+ + MEDIA_LOCATION + " TEXT PRIMARY KEY NOT NULL, "
+ MEDIA_TIME + " INTEGER, "
+ MEDIA_LENGTH + " INTEGER, "
+ MEDIA_TYPE + " INTEGER, "
@@ -219,7 +221,7 @@ public class DatabaseManager {
ContentValues values = new ContentValues();
- values.put(MEDIA_PATH, media.getPath());
+ values.put(MEDIA_LOCATION, media.getLocation());
values.put(MEDIA_TIME, media.getTime());
values.put(MEDIA_LENGTH, media.getLength());
values.put(MEDIA_TYPE, media.getType());
@@ -259,7 +261,7 @@ public class DatabaseManager {
cursor = mDb.query(
MEDIA_TABLE_NAME,
- new String[] { MEDIA_PATH },
+ new String[] { MEDIA_LOCATION },
null, null, null, null, null);
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
@@ -293,7 +295,7 @@ public class DatabaseManager {
MEDIA_ARTIST, //5 string
MEDIA_GENRE, //6 string
MEDIA_ALBUM, //7 string
- MEDIA_PATH, //8 string
+ MEDIA_LOCATION, //8 string
MEDIA_TABLE_NAME,
CHUNK_SIZE,
chunk_count * CHUNK_SIZE), null);
@@ -305,12 +307,19 @@ public class DatabaseManager {
picture = BitmapFactory.decodeByteArray(blob, 0, blob.length);
}
- Media media = new Media(context, new File(cursor.getString(8)), cursor.getLong(0),
- cursor.getLong(1), cursor.getInt(2),
- picture, cursor.getString(4),
- cursor.getString(5), cursor.getString(6),
- cursor.getString(7));
- medias.put(media.getPath(), media);
+ try {
+ Media media = new Media(context, new File(Util.VLCPathToURI(cursor.getString(8))), cursor.getLong(0),
+ cursor.getLong(1), cursor.getInt(2),
+ picture, cursor.getString(4),
+ cursor.getString(5), cursor.getString(6),
+ cursor.getString(7));
+ medias.put(media.getLocation(), media);
+ } catch (URISyntaxException e) {
+ // URISyntax
+ // Exception: Cannot happen
+ // But Java forced me
+ }
+
picture = null;
count++;
} while (cursor.moveToNext());
@@ -342,7 +351,7 @@ public class DatabaseManager {
MEDIA_GENRE, //6 string
MEDIA_ALBUM //7 string
},
- MEDIA_PATH + "=?",
+ MEDIA_LOCATION + "=?",
new String[] { path },
null, null, null);
if (cursor.moveToFirst()) {
@@ -352,18 +361,22 @@ public class DatabaseManager {
picture = BitmapFactory.decodeByteArray(blob, 0, blob.length);
}
- media = new Media(context, new File(path), cursor.getLong(0),
- cursor.getLong(1), cursor.getInt(2),
- picture, cursor.getString(4),
- cursor.getString(5), cursor.getString(6),
- cursor.getString(7));
+ try {
+ media = new Media(context, new File(Util.VLCPathToURI(path)), cursor.getLong(0),
+ cursor.getLong(1), cursor.getInt(2),
+ picture, cursor.getString(4),
+ cursor.getString(5), cursor.getString(6),
+ cursor.getString(7));
+ } catch (URISyntaxException e) {
+ //not possible, but java requires it
+ }
}
cursor.close();
return media;
}
public synchronized void removeMedia(String path) {
- mDb.delete(MEDIA_TABLE_NAME, MEDIA_PATH + "=?", new String[] { path });
+ mDb.delete(MEDIA_TABLE_NAME, MEDIA_LOCATION + "=?", new String[] { path });
}
public synchronized void updateMedia(String path, mediaColumn col,
@@ -379,7 +392,7 @@ public class DatabaseManager {
default:
return;
}
- mDb.update(MEDIA_TABLE_NAME, values, MEDIA_PATH + "=?", new String[] { path });
+ mDb.update(MEDIA_TABLE_NAME, values, MEDIA_LOCATION + "=?", new String[] { path });
}
/**
diff --git a/vlc-android/src/org/videolan/vlc/LibVLC.java b/vlc-android/src/org/videolan/vlc/LibVLC.java
index e3f7682..8ce3761 100644
--- a/vlc-android/src/org/videolan/vlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/vlc/LibVLC.java
@@ -218,8 +218,8 @@ public class LibVLC {
/**
* Return true if there is a video track in the file
*/
- public long getLengthFromFile(String filePath) {
- return getLengthFromFile(mLibVlcInstance, filePath);
+ public long getLengthFromLocation(String filePath) {
+ return getLengthFromLocation(mLibVlcInstance, filePath);
}
/**
@@ -361,7 +361,7 @@ public class LibVLC {
/**
* Return true if there is a video track in the file
*/
- private native long getLengthFromFile(int instance, String filePath);
+ private native long getLengthFromLocation(int instance, String filePath);
private native void setEventManager(EventManager eventManager);
diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index 9f1662c..fd83089 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -21,6 +21,8 @@
package org.videolan.vlc;
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
import android.content.Context;
import android.graphics.Bitmap;
@@ -62,7 +64,13 @@ public class Media implements Comparable<Media> {
private String mEncodedBy;
private String mTrackID;
- private File mFile;
+ private String mLocation;
+ private String mFilename;
+ /**
+ * To maintain compatibility in a couple of places
+ * Only used internally now
+ */
+ private File mFile_internal;
private long mTime = 0;
private long mLength = 0;
private int mType;
@@ -71,19 +79,33 @@ public class Media implements Comparable<Media> {
private Bitmap mPicture;
/**
- * Create an new Media
- * @param file: path on the local storage
+ * Create a new Media
+ * @param context Application context of the caller
+ * @param MRL the file's MRL (media resource locator)
+ * @param addToDb Should it be added to the file database?
*/
- public Media(Context context, File file) {
- this.mFile = file;
+ public Media(Context context, String MRL, Boolean addToDb) {
+ mFile_internal = null;
+ mLocation = MRL;
+ try {
+ URL urlobj = new URL(MRL);
+ mFilename = urlobj.getFile().substring(urlobj.getFile().lastIndexOf('/') + 1);
+ /* empty hosts are awkward */
+ if(mFilename.equals("")) {
+ mFilename = urlobj.getHost();
+ }
+ } catch (MalformedURLException e1) {
+ mFilename = "";
+ }
+
LibVLC mLibVlc = null;
try {
mLibVlc = LibVLC.getInstance();
- mType = (mLibVlc.hasVideoTrack(file.getPath())) ? TYPE_VIDEO : TYPE_AUDIO;
- mLength = mLibVlc.getLengthFromFile(file.getPath());
+ mType = (mLibVlc.hasVideoTrack(mLocation)) ? TYPE_VIDEO : TYPE_AUDIO;
+ mLength = mLibVlc.getLengthFromLocation(mLocation);
- String[] array = mLibVlc.readMediaMeta(file.getPath());
+ String[] array = mLibVlc.readMediaMeta(mLocation);
int i;
for (i = 0; i < array.length; i++) {
@@ -108,14 +130,30 @@ public class Media implements Comparable<Media> {
e.printStackTrace();
}
- // Add this item to database
- DatabaseManager db = DatabaseManager.getInstance(context);
- db.addMedia(this);
+ if(addToDb) {
+ // Add this item to database
+ DatabaseManager db = DatabaseManager.getInstance(context);
+ db.addMedia(this);
+ }
+ }
+
+ /**
+ * Create from file
+ *
+ * @param context Context of the caller
+ * @param file File object of the file to be added
+ */
+ public Media(Context context, File file) {
+ this(context, Util.FixURI(file.toURI()), true);
+ mFile_internal = file;
+ mFilename = mFile_internal.getName().substring(0, mFile_internal.getName().lastIndexOf('.'));
}
public Media(Context context, File file, long time, long length, int type,
Bitmap picture, String title, String artist, String genre, String album) {
- mFile = file;
+ mFile_internal = file;
+ mLocation = Util.FixURI(file.toURI().toString());
+ mFilename = mFile_internal.getName().substring(0, mFile_internal.getName().lastIndexOf('.'));
mTime = time;
mLength = length;
mType = type;
@@ -135,12 +173,8 @@ public class Media implements Comparable<Media> {
another.getTitle().toUpperCase());
}
- public File getFile() {
- return mFile;
- }
-
- public String getPath() {
- return mFile.getPath();
+ public String getLocation() {
+ return mLocation;
}
public void updateMeta() {
@@ -148,7 +182,7 @@ public class Media implements Comparable<Media> {
}
public String getFileName() {
- return mFile.getName().substring(0, mFile.getName().lastIndexOf('.'));
+ return mFilename;
}
public long getTime() {
@@ -182,17 +216,16 @@ public class Media implements Comparable<Media> {
public void setPicture(Context context, Bitmap p) {
Log.d(TAG, "Set new picture for " + getTitle());
DatabaseManager.getInstance(context).updateMedia(
- mFile.getPath(),
+ mLocation,
DatabaseManager.mediaColumn.MEDIA_PICTURE,
p);
mPicture = p;
}
public String getTitle() {
- if (mTitle == null)
- return mFile.getName().substring(0, mFile.getName().lastIndexOf('.'));
- else
- return mTitle;
+ /* should never happen */
+ assert (mTitle != null);
+ return mTitle;
}
public String getArtist() {
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index 3a78992..63bc235 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -23,6 +23,8 @@ package org.videolan.vlc;
import java.io.File;
import java.io.FileFilter;
import java.lang.Thread.State;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -135,7 +137,7 @@ public class MediaLibrary {
public Media getMediaItem(String path) {
for (int i = 0; i < mItemList.size(); i++) {
Media item = mItemList.get(i);
- if (item.getPath().equals(path)) {
+ if (item.getLocation().equals(path)) {
return item;
}
}
@@ -183,9 +185,9 @@ public class MediaLibrary {
HashMap<String, Media> existingMedias = mDBManager.getMedias(mContext);
// list of all added files
- HashSet<File> addedFiles = new HashSet<File>();
+ HashSet<String> addedLocations = new HashSet<String>();
- // clear all old item
+ // clear all old items
mItemList.clear();
MediaItemFilter mediaFileFilter = new MediaItemFilter();
@@ -221,18 +223,17 @@ public class MediaLibrary {
File file = f[i];
if (file.isFile()) {
-
MainActivity.sendTextInfo(mContext, file.getName(), count, total);
count++;
-
- if (existingMedias.containsKey(file.getPath())) {
+ String fileURI = Util.FixURI(file.toURI().toString());
+ if (existingMedias.containsKey(fileURI)) {
/** only add file if it is not already in the
* list. eg. if user select an subfolder as well
*/
- if (!addedFiles.contains(file)) {
+ if (!addedLocations.contains(fileURI)) {
// get existing media item from database
- mItemList.add(existingMedias.get(file.getPath()));
- addedFiles.add(file);
+ mItemList.add(existingMedias.get(fileURI));
+ addedLocations.add(fileURI);
}
} else {
// create new media item
@@ -252,8 +253,8 @@ public class MediaLibrary {
}
// remove file from database
- for (File file : addedFiles) {
- existingMedias.remove(file.getPath());
+ for (String fileURI : addedLocations) {
+ existingMedias.remove(fileURI);
}
for (String path : existingMedias.keySet()) {
mDBManager.removeMedia(path);
diff --git a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
index 3e418fb..09eb48a 100644
--- a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
+++ b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
@@ -122,7 +122,7 @@ public class ThumbnailerManager extends Thread {
// Get the thumbnail.
Bitmap thumbnail = Bitmap.createBitmap(width, height, Config.ARGB_8888);
//Log.i(TAG, "create new bitmap for: " + item.getName());
- byte[] b = mLibVlc.getThumbnail(item.getPath(), width, height);
+ byte[] b = mLibVlc.getThumbnail(item.getLocation(), width, height);
if (b == null) // We were not able to create a thumbnail for this item.
continue;
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index bfdec1a..9f13dd1 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -21,6 +21,8 @@
package org.videolan.vlc;
import java.lang.reflect.Field;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.text.DecimalFormat;
import android.content.Context;
@@ -40,6 +42,34 @@ public class Util {
}
/**
+ * A function to fix up the broken Java URI format
+ * LibVLC expects the file:///sdcard/... format, but by default
+ * Java gives the file:/sdcard format, which angers LibVLC
+ * Reference: http://stackoverflow.com/questions/1131273/java-file-touri-tourl-on-windows-file
+ *
+ * @param javaURI The URI returned by Java
+ * @return Fixed URI for use by LibVLC
+ */
+ public static String FixURI(String javaURI) {
+ return javaURI.replace("file:/", "file:///");
+ }
+
+ public static String FixURI(URI uri) {
+ return FixURI(uri.toString());
+ }
+
+ /**
+ * Function to convert a LibVLC path back to an URI
+ *
+ * @param path the libvlc path
+ * @return the URI
+ * @throws URISyntaxException
+ */
+ public static URI VLCPathToURI(String path) throws URISyntaxException {
+ return new URI(path.replace("file://", "file:"));
+ }
+
+ /**
* Convert time to a string
* @param millis e.g.time/length from file
* @return formated string (hh:)mm:ss
diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java b/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java
index 0176cbd..118d5be 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java
@@ -122,7 +122,7 @@ public class SearchActivity extends ListActivity {
continue;
boolean add = true;
String name = item.getTitle().toLowerCase();
- String path = item.getPath().toLowerCase();
+ String path = item.getLocation().toLowerCase();
for (int k = 0; k < keys.length; k++) {
if (!(name.contains(keys[k].toLowerCase()) || path.contains(keys[k].toLowerCase()))) {
add = false;
@@ -252,15 +252,15 @@ public class SearchActivity extends ListActivity {
Intent intent;
if (item.getType() == Media.TYPE_VIDEO) {
intent = new Intent(this, VideoPlayerActivity.class);
- intent.putExtra("filePath", item.getPath());
+ intent.putExtra("itemLocation", item.getLocation());
} else {
ArrayList<String> arr = new ArrayList<String>();
for (int i = 0; i < getListAdapter().getCount(); i++) {
Media audioItem = (Media) getListAdapter().getItem(i);
if (audioItem.getType() == Media.TYPE_AUDIO)
- arr.add(audioItem.getPath());
+ arr.add(audioItem.getLocation());
}
- AudioServiceController.getInstance().load(arr, arr.indexOf(item.getPath()));
+ AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation()));
intent = new Intent(this, AudioPlayerActivity.class);
}
startActivity(intent);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserActivity.java
index 0e9a76f..5681450 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserActivity.java
@@ -249,7 +249,7 @@ public class AudioBrowserActivity extends Activity implements ISortable {
private Comparator<Media> byPath = new Comparator<Media>() {
public int compare(Media m1, Media m2) {
- return String.CASE_INSENSITIVE_ORDER.compare(m1.getFile().getPath(), m2.getFile().getPath());
+ return String.CASE_INSENSITIVE_ORDER.compare(m1.getLocation(), m2.getLocation());
};
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListActivity.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListActivity.java
index 1a3a68a..b5fe66d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListActivity.java
@@ -170,7 +170,7 @@ public class AudioListActivity extends ListActivity {
private Comparator<Media> byPath = new Comparator<Media>() {
public int compare(Media m1, Media m2) {
- return String.CASE_INSENSITIVE_ORDER.compare(m1.getFile().getPath(), m2.getFile().getPath());
+ return String.CASE_INSENSITIVE_ORDER.compare(m1.getLocation(), m2.getLocation());
};
};
@@ -220,7 +220,7 @@ public class AudioListActivity extends ListActivity {
for (int i = 0; i < audioList.size(); i++) {
Media media = audioList.get(i);
- if (currentItem != null && currentItem.equals(media.getPath()))
+ if (currentItem != null && currentItem.equals(media.getLocation()))
currentIndex = i;
mSongsAdapter.add(media);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
index 530cf62..c383a70 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
@@ -102,7 +102,7 @@ public class AudioPlaylistAdapter extends ArrayAdapter<String> {
if (position >= 0 && position < mTitles.size()) {
List<Media> mediaList = mPlaylists.get(mTitles.get(position));
for (int i = 0; i < mediaList.size(); i++) {
- playlist.add(mediaList.get(i).getPath());
+ playlist.add(mediaList.get(i).getLocation());
}
}
return playlist;
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioSongsListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioSongsListAdapter.java
index b9d2c4a..2c534ec 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioSongsListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioSongsListAdapter.java
@@ -85,14 +85,14 @@ public class AudioSongsListAdapter extends ArrayAdapter<Media> {
public List<String> getPath(int position) {
List<String> paths = new ArrayList<String>();
if (position >= 0 && position < mMediaList.size())
- paths.add(mMediaList.get(position).getPath());
+ paths.add(mMediaList.get(position).getLocation());
return paths;
}
public List<String> getPaths() {
List<String> paths = new ArrayList<String>();
for (int i = 0; i < mMediaList.size(); i++) {
- paths.add(mMediaList.get(i).getPath());
+ paths.add(mMediaList.get(i).getLocation());
}
return paths;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
index bad0544..b27a291 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
@@ -52,7 +52,7 @@ public class MediaInfoActivity extends ListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_info);
- String path = getIntent().getExtras().getString("filePath");
+ String path = getIntent().getExtras().getString("itemLocation");
if (path == null)
return;
mItem = MediaLibrary.getInstance(this).getMediaItem(path);
@@ -81,7 +81,7 @@ public class MediaInfoActivity extends ListActivity {
return;
}
- mTracks = mLibVlc.readTracksInfo(mItem.getPath());
+ mTracks = mLibVlc.readTracksInfo(mItem.getLocation());
mHandler.sendEmptyMessage(NEW_TEXT);
int width = Math.min(getWindowManager().getDefaultDisplay().getWidth(),
@@ -91,7 +91,7 @@ public class MediaInfoActivity extends ListActivity {
// Get the thumbnail.
mImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- byte[] b = mLibVlc.getThumbnail(mItem.getPath(), width, height);
+ byte[] b = mLibVlc.getThumbnail(mItem.getLocation(), width, height);
if (b == null) // We were not able to create a thumbnail for this item.
return;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java
index c038d18..e567baf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java
@@ -103,7 +103,7 @@ public class VideoListActivity extends ListActivity implements ISortable {
Media item = (Media) getListAdapter().getItem(position);
Intent intent = new Intent(this, VideoPlayerActivity.class);
- intent.putExtra("filePath", item.getPath());
+ intent.putExtra("itemLocation", item.getLocation());
startActivity(intent);
super.onListItemClick(l, v, position, id);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index b230b42..4a96c2b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -144,7 +144,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
holder.thumbnail.setImageBitmap(thumbnail);
}
- holder.title.setTextColor(media.getPath().equals(mLastPath) ? Color.RED : Color.WHITE);
+ holder.title.setTextColor(media.getLocation().equals(mLastPath) ? Color.RED : Color.WHITE);
holder.more.setTag(media);
holder.more.setOnClickListener(moreClickListener);
@@ -157,7 +157,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
public void onClick(View v) {
Media item = (Media) v.getTag();
Intent intent = new Intent(getContext(), MediaInfoActivity.class);
- intent.putExtra("filePath", item.getPath());
+ intent.putExtra("itemLocation", item.getLocation());
getContext().startActivity(intent);
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 26db89f..b9ca63b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -798,7 +798,7 @@ public class VideoPlayerActivity extends Activity {
path = getIntent().getDataString();
} else {
/* Started from VideoListActivity */
- path = getIntent().getExtras().getString("filePath");
+ path = getIntent().getExtras().getString("itemLocation");
}
if (path != null && path.length() > 0) {
--
1.7.5.4
More information about the Android
mailing list