Skip to content
Snippets Groups Projects
Commit 55cfdfce authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix mrl encoding passed to medialibrary


Signed-off-by: default avatarGeoffrey Métais <geoffrey.metais@gmail.com>
parent faa0bfbc
No related branches found
No related tags found
No related merge requests found
......@@ -117,8 +117,7 @@ public class Medialibrary {
}
public void discover(@NonNull String path) {
if (mIsInitiated)
nativeDiscover(Tools.encodeVLCMrl(path));
if (mIsInitiated) nativeDiscover(Tools.encodeVLCMrl(path));
}
public void removeFolder(@NonNull String mrl) {
......@@ -274,13 +273,13 @@ public class Medialibrary {
@Nullable
public MediaWrapper getMedia(Uri uri) {
final String vlcMrl = Tools.encodeVLCMrl(Uri.decode(uri.toString()));
final String vlcMrl = Tools.encodeVLCMrl(uri.toString());
return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeGetMediaFromMrl(vlcMrl) : null;
}
@Nullable
public MediaWrapper getMedia(String mrl) {
final String vlcMrl = Tools.encodeVLCMrl(Uri.decode(mrl));
final String vlcMrl = Tools.encodeVLCMrl(mrl);
return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeGetMediaFromMrl(vlcMrl) : null;
}
......
......@@ -125,8 +125,7 @@ public class Tools {
}
static String encodeVLCMrl(String mrl) {
if (mrl.startsWith("/"))
mrl = "file://"+mrl;
return VLCUtil.encodeVLCString(Uri.encode(mrl, ":/"));
if (mrl.startsWith("/")) mrl = "file://"+mrl;
return VLCUtil.encodeVLCString(Uri.encode(Uri.decode(mrl), ":/"));
}
}
......@@ -167,15 +167,12 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
long id = mw.getId();
if (id == 0) {
MediaWrapper media = mMedialibrary.getMedia(mw.getUri());
if (media != null)
ids.add(media.getId());
if (media != null) ids.add(media.getId());
else {
media = mMedialibrary.addMedia(mw.getLocation());
if (media != null)
ids.add(media.getId());
if (media != null) ids.add(media.getId());
}
} else
ids.add(id);
} else ids.add(id);
}
playlist.append(ids);
if (mCallBack != null) mCallBack.run();
......
......@@ -2,7 +2,6 @@ package org.videolan.vlc.gui.helpers;
import android.content.Intent;
import android.net.Uri;
import org.videolan.vlc.MediaParsingService;
import org.videolan.vlc.VLCApplication;
......@@ -14,14 +13,14 @@ public class MedialibraryUtils {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
VLCApplication.getMLInstance().removeFolder(Uri.decode(path));
VLCApplication.getMLInstance().removeFolder(path);
}
});
}
public static void addDir(final String path) {
final Intent intent = new Intent(Constants.ACTION_DISCOVER, null, VLCApplication.getAppContext(), MediaParsingService.class);
intent.putExtra(Constants.EXTRA_PATH, Uri.decode(path));
intent.putExtra(Constants.EXTRA_PATH, path);
VLCApplication.getAppContext().startService(intent);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment