Commit b16517b1 authored by Geoffrey Métais's avatar Geoffrey Métais Committed by Geoffrey Métais

Medialibrary: Add ext media removal

parent 3a6b017b
...@@ -311,6 +311,13 @@ AndroidMediaLibrary::addMedia(const std::string& mrl) ...@@ -311,6 +311,13 @@ AndroidMediaLibrary::addMedia(const std::string& mrl)
return p_ml->addExternalMedia(mrl); return p_ml->addExternalMedia(mrl);
} }
bool
AndroidMediaLibrary::removeExternalMedia(long id)
{
auto media = p_ml->media(id);
return media != nullptr && p_ml->removeExternalMedia(media);
}
medialibrary::MediaPtr medialibrary::MediaPtr
AndroidMediaLibrary::addStream(const std::string& mrl, const std::string& title) AndroidMediaLibrary::addStream(const std::string& mrl, const std::string& title)
{ {
......
...@@ -72,6 +72,7 @@ public: ...@@ -72,6 +72,7 @@ public:
medialibrary::MediaPtr media(long id); medialibrary::MediaPtr media(long id);
medialibrary::MediaPtr media(const std::string& mrl); medialibrary::MediaPtr media(const std::string& mrl);
medialibrary::MediaPtr addMedia(const std::string& mrl); medialibrary::MediaPtr addMedia(const std::string& mrl);
bool removeExternalMedia(long id);
medialibrary::MediaPtr addStream(const std::string& mrl, const std::string& title); medialibrary::MediaPtr addStream(const std::string& mrl, const std::string& title);
medialibrary::Query<medialibrary::IMedia> videoFiles( const medialibrary::QueryParameters* params = nullptr ); medialibrary::Query<medialibrary::IMedia> videoFiles( const medialibrary::QueryParameters* params = nullptr );
medialibrary::Query<medialibrary::IMedia> audioFiles( const medialibrary::QueryParameters* params = nullptr ); medialibrary::Query<medialibrary::IMedia> audioFiles( const medialibrary::QueryParameters* params = nullptr );
......
...@@ -695,6 +695,12 @@ addMedia(JNIEnv* env, jobject thiz, jstring mrl) { ...@@ -695,6 +695,12 @@ addMedia(JNIEnv* env, jobject thiz, jstring mrl) {
return mw; return mw;
} }
jboolean
removeExternalMedia(JNIEnv* env, jobject thiz, jlong id) {
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
return aml->removeExternalMedia(id);
}
jobject jobject
addStream(JNIEnv* env, jobject thiz, jstring mrl, jstring title) { addStream(JNIEnv* env, jobject thiz, jstring mrl, jstring title) {
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz); AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
...@@ -1716,6 +1722,7 @@ static JNINativeMethod methods[] = { ...@@ -1716,6 +1722,7 @@ static JNINativeMethod methods[] = {
{"nativeGetMedia", "(J)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getMedia }, {"nativeGetMedia", "(J)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getMedia },
{"nativeGetMediaFromMrl", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getMediaFromMrl }, {"nativeGetMediaFromMrl", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getMediaFromMrl },
{"nativeAddMedia", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)addMedia }, {"nativeAddMedia", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)addMedia },
{"nativeRemoveExternalMedia", "(J)Z", (void*)removeExternalMedia },
{"nativeAddStream", "(Ljava/lang/String;Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)addStream }, {"nativeAddStream", "(Ljava/lang/String;Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)addStream },
{"nativeGetVideoCount", "()I", (void*)getVideoCount }, {"nativeGetVideoCount", "()I", (void*)getVideoCount },
{"nativeGetAudioCount", "()I", (void*)getAudioCount }, {"nativeGetAudioCount", "()I", (void*)getAudioCount },
......
...@@ -444,6 +444,10 @@ public class Medialibrary { ...@@ -444,6 +444,10 @@ public class Medialibrary {
return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeAddMedia(vlcMrl) : null; return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeAddMedia(vlcMrl) : null;
} }
public boolean removeExternalMedia(long id) {
return mIsInitiated && nativeRemoveExternalMedia(id);
}
@Nullable @Nullable
public MediaWrapper addStream(String mrl, String title) { public MediaWrapper addStream(String mrl, String title) {
final String vlcMrl = Tools.encodeVLCMrl(mrl); final String vlcMrl = Tools.encodeVLCMrl(mrl);
...@@ -969,6 +973,7 @@ public class Medialibrary { ...@@ -969,6 +973,7 @@ public class Medialibrary {
private native MediaWrapper nativeGetMedia(long id); private native MediaWrapper nativeGetMedia(long id);
private native MediaWrapper nativeGetMediaFromMrl(String mrl); private native MediaWrapper nativeGetMediaFromMrl(String mrl);
private native MediaWrapper nativeAddMedia(String mrl); private native MediaWrapper nativeAddMedia(String mrl);
private native boolean nativeRemoveExternalMedia(long id);
private native MediaWrapper nativeAddStream(String mrl, String title); private native MediaWrapper nativeAddStream(String mrl, String title);
private native MediaWrapper[] nativeGetVideos(); private native MediaWrapper[] nativeGetVideos();
private native MediaWrapper[] nativeGetSortedVideos(int sort, boolean desc); private native MediaWrapper[] nativeGetSortedVideos(int sort, boolean desc);
......
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