[Android] libvlc: add a simple playMrl(String mrl)

Sébastien Toque git at videolan.org
Sun Dec 8 14:32:17 CET 2013


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Dec  8 14:31:54 2013 +0100| [79f65dd4749e6efd913972bd8012f504be44beb9] | committer: Sébastien Toque

libvlc: add a simple playMrl(String mrl)

Close #10007

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=79f65dd4749e6efd913972bd8012f504be44beb9
---

 vlc-android/src/org/videolan/libvlc/LibVLC.java    |   12 ++++++
 vlc-android/src/org/videolan/libvlc/MediaList.java |   45 +++++++++++---------
 2 files changed, 36 insertions(+), 21 deletions(-)

diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index 8451aa9..0c67637 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -420,6 +420,18 @@ public class LibVLC {
         playMrl(mLibVlcInstance, mrl, options);
     }
 
+    /**
+     * Play an mrl
+     *
+     * @param position The index of the media
+     */
+    public void playMrl(String mrl) {
+        // index=-1 will return options from libvlc instance without relying on MediaList
+        String[] options = mMediaList.getMediaOptions(-1);
+        mInternalMediaPlayerIndex = 0;
+        playMrl(mLibVlcInstance, mrl, options);
+    }
+
     public TrackInfo[] readTracksInfo(String mrl) {
         return readTracksInfo(mLibVlcInstance, mrl);
     }
diff --git a/vlc-android/src/org/videolan/libvlc/MediaList.java b/vlc-android/src/org/videolan/libvlc/MediaList.java
index 32e97a3..5990737 100644
--- a/vlc-android/src/org/videolan/libvlc/MediaList.java
+++ b/vlc-android/src/org/videolan/libvlc/MediaList.java
@@ -163,31 +163,34 @@ public class MediaList {
         return mInternalList.get(position).m.getLocation();
     }
 
-    private String[] getMediaOptions(int position) {
-        if (!isValid(position))
-            return null;
-        boolean noOmx = mInternalList.get(position).noOmx;
-        boolean noVideo = mInternalList.get(position).noVideo;
+    public String[] getMediaOptions(int position) {
+        boolean noOmx = !mLibVLC.useIOMX();
+        boolean noVideo = false;
+        if (isValid(position))
+        {
+            if (!noOmx)
+                noOmx = mInternalList.get(position).noOmx;
+            noVideo = mInternalList.get(position).noVideo;
+        }
         ArrayList<String> options = new ArrayList<String>();
 
         if (!noOmx) {
-            if (mLibVLC.useIOMX()) {
-                /*
-                 * Set higher caching values if using iomx decoding, since some omx
-                 * decoders have a very high latency, and if the preroll data isn't
-                 * enough to make the decoder output a frame, the playback timing gets
-                 * started too soon, and every decoded frame appears to be too late.
-                 * On Nexus One, the decoder latency seems to be 25 input packets
-                 * for 320x170 H.264, a few packets less on higher resolutions.
-                 * On Nexus S, the decoder latency seems to be about 7 packets.
-                 */
-                options.add(":file-caching=1500");
-                options.add(":network-caching=1500");
-                options.add(":codec=mediacodec,iomx,all");
-            }
-            if (noVideo)
-                options.add(":no-video");
+            /*
+             * Set higher caching values if using iomx decoding, since some omx
+             * decoders have a very high latency, and if the preroll data isn't
+             * enough to make the decoder output a frame, the playback timing gets
+             * started too soon, and every decoded frame appears to be too late.
+             * On Nexus One, the decoder latency seems to be 25 input packets
+             * for 320x170 H.264, a few packets less on higher resolutions.
+             * On Nexus S, the decoder latency seems to be about 7 packets.
+             */
+            options.add(":file-caching=1500");
+            options.add(":network-caching=1500");
+            options.add(":codec=mediacodec,iomx,all");
         }
+        if (noVideo)
+            options.add(":no-video");
+
         return options.toArray(new String[options.size()]);
     }
 



More information about the Android mailing list