Commit ac8db153 authored by Geoffrey Métais's avatar Geoffrey Métais

Rename locationFromMrl to encodeVLCString

parent 1d0b9879
......@@ -438,7 +438,7 @@ public class Media extends VLCObject<Media.Event> {
*/
public Media(LibVLC libVLC, Uri uri) {
super(libVLC);
nativeNewFromLocation(libVLC, VLCUtil.locationFromUri(uri));
nativeNewFromLocation(libVLC, VLCUtil.encodeVLCUri(uri));
mUri = uri;
}
......
......@@ -977,7 +977,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
* @return true on success.
*/
public boolean addSlave(int type, Uri uri, boolean select) {
return nativeAddSlave(type, VLCUtil.locationFromUri(uri), select);
return nativeAddSlave(type, VLCUtil.encodeVLCUri(uri), select);
}
/**
......
......@@ -548,15 +548,15 @@ public class VLCUtil {
return Uri.parse(sb.toString());
}
public static String locationFromUri(@NonNull Uri uri) {
return locationFromMrl(uri.toString());
public static String encodeVLCUri(@NonNull Uri uri) {
return encodeVLCString(uri.toString());
}
/**
* VLC only acccepts "-._~" in Mrl format, android Uri accepts "_-!.~'()*".
* Therefore, encode the characters authorized by Android Uri when creating a mrl from an Uri.
*/
public static String locationFromMrl(@NonNull String mrl) {
public static String encodeVLCString(@NonNull String mrl) {
final char[] array = mrl.toCharArray();
final StringBuilder sb = new StringBuilder(array.length * 2);
......
......@@ -92,7 +92,7 @@ public class Medialibrary {
}
public boolean addDevice(@NonNull String uuid, @NonNull String path, boolean removable, boolean notify) {
return nativeAddDevice(uuid, Tools.encodeVLCMrl(path), removable, notify);
return nativeAddDevice(VLCUtil.encodeVLCString(uuid), Tools.encodeVLCMrl(path), removable, notify);
}
public void discover(@NonNull String path) {
......@@ -112,7 +112,7 @@ public class Medialibrary {
}
public boolean removeDevice(String uuid) {
return mIsInitiated && nativeRemoveDevice(uuid);
return mIsInitiated && nativeRemoveDevice(VLCUtil.encodeVLCString(uuid));
}
@Override
......@@ -224,7 +224,7 @@ public class Medialibrary {
}
public boolean addToHistory(String mrl, String title) {
return mIsInitiated && nativeAddToHistory(mrl, title);
return mIsInitiated && nativeAddToHistory(Tools.encodeVLCMrl(mrl), VLCUtil.encodeVLCString(title));
}
public MediaWrapper getMedia(long id) {
......@@ -232,7 +232,7 @@ public class Medialibrary {
}
public MediaWrapper getMedia(Uri uri) {
return mIsInitiated ? nativeGetMediaFromMrl(VLCUtil.locationFromUri(uri)) : null;
return mIsInitiated ? nativeGetMediaFromMrl(VLCUtil.encodeVLCUri(uri)) : null;
}
public MediaWrapper getMedia(String mrl) {
......
......@@ -127,6 +127,6 @@ public class Tools {
public static String encodeVLCMrl(String mrl) {
if (mrl.startsWith("/"))
mrl = "file://"+mrl;
return VLCUtil.locationFromMrl(mrl);
return VLCUtil.encodeVLCString(mrl);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment