[Android] [PATCH 1/2] Use MRLs and libvlc_media_new_location everywhere
Rafaël Carré
funman at videolan.org
Mon Mar 12 20:51:43 CET 2012
Hi,
Le 2012-03-10 23:43, Edward Wang a écrit :
> ---
> As suggested by funman
> Tested
>
> vlc-android/jni/libvlcjni.c | 6 +-
> vlc-android/src/org/videolan/vlc/AudioService.java | 14 ++--
> .../src/org/videolan/vlc/DatabaseManager.java | 34 +++++----
> vlc-android/src/org/videolan/vlc/Media.java | 79 ++++++++++++++------
> vlc-android/src/org/videolan/vlc/MediaLibrary.java | 2 +-
> .../src/org/videolan/vlc/ThumbnailerManager.java | 2 +-
> vlc-android/src/org/videolan/vlc/Util.java | 18 +++++
> .../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 | 4 +-
> .../videolan/vlc/gui/video/VideoListActivity.java | 2 +-
> .../videolan/vlc/gui/video/VideoListAdapter.java | 4 +-
> 15 files changed, 121 insertions(+), 64 deletions(-)
>
> diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
> index ee8bf31..0f7cd88 100644
> --- a/vlc-android/jni/libvlcjni.c
> +++ b/vlc-android/jni/libvlcjni.c
> @@ -38,9 +38,9 @@ libvlc_media_t *new_media(jint instance, JNIEnv *env, jobject thiz, jstring file
> {
> 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, filePath, &isCopy);
> + libvlc_media_t *p_md = libvlc_media_new_location(libvlc, psz_location);
> + (*env)->ReleaseStringUTFChars(env, filePath, psz_location);
filePath should be changed too.
> if (!p_md)
> return NULL;
>
> 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());
getLocation still returns a String, shouldn't it be changed to URI?
> 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..d42a16e 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);
> @@ -310,7 +312,7 @@ public class DatabaseManager {
> picture, cursor.getString(4),
> cursor.getString(5), cursor.getString(6),
> cursor.getString(7));
> - medias.put(media.getPath(), media);
> + medias.put(media.getLocation(), media);
> picture = null;
> count++;
> } while (cursor.moveToNext());
> @@ -342,7 +344,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 +354,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(new URI(path.replace("file:///", "file:/"))), cursor.getLong(0),
shouldn't it be "file://", "file:" ?
> + 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 +385,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/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
> index 9f1662c..836550f 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;
> @@ -72,18 +80,32 @@ public class Media implements Comparable<Media> {
>
> /**
> * Create an new Media
> - * @param file: path on the local storage
> + * @param context Application context of the caller
> + * @param MRL the file's MRL/URI/URL locator
URL locator?
Just say 'MRL' IMO.
> + * @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.getLengthFromFile(mLocation);
LengthFromFile should be renamed
>
> - 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..cf553b8 100644
> --- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
> +++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
> @@ -135,7 +135,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;
> }
> }
> 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..860bf42 100644
> --- a/vlc-android/src/org/videolan/vlc/Util.java
> +++ b/vlc-android/src/org/videolan/vlc/Util.java
> @@ -21,6 +21,7 @@
> package org.videolan.vlc;
>
> import java.lang.reflect.Field;
> +import java.net.URI;
> import java.text.DecimalFormat;
>
> import android.content.Context;
> @@ -40,6 +41,23 @@ 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());
> + }
> +
> + /**
> * 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..6bf73b5 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("filePath", 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..cf53e88 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoActivity.java
> @@ -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..c75d2b3 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("filePath", 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..81459e2 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("filePath", item.getLocation());
doesn't look good
> getContext().startActivity(intent);
> }
> };
I didn't read the whole patch but I suspect there are still confusions
between file paths and URIs.
More information about the Android
mailing list