Commit 8100f162 authored by Edward Wang's avatar Edward Wang

Util: add getOrCreateMedia

parent a8ed63c9
......@@ -25,6 +25,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.VLCApplication;
import android.content.Context;
......@@ -76,6 +79,21 @@ public class Util {
}
}
/**
* Retrieve the existing media object from the media library or create a
* new one from the given MRL.
*
* @param libVLC LibVLC instance
* @param mrl MRL of the media
* @return A media object from the media library or newly created
*/
public static Media getOrCreateMedia(LibVLC libVLC, String mrl) {
Media mlItem = MediaLibrary.getInstance().getMediaItem(mrl);
if(mlItem == null)
mlItem = new Media(libVLC, mrl);
return mlItem;
}
/**
* Get a resource id from an attribute id.
* @param context
......
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