[Android] LibVLC: add Buffering event

Alexandre Perraud git at videolan.org
Thu May 26 16:35:58 CEST 2016


vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Thu May 26 16:34:04 2016 +0200| [1c4b6c51cb33dc884f78e7c7bb4b9e9d8eff18fc] | committer: Alexandre Perraud

LibVLC: add Buffering event

> https://code.videolan.org/videolan/vlc-android/commit/1c4b6c51cb33dc884f78e7c7bb4b9e9d8eff18fc
---

 libvlc/jni/libvlcjni-mediaplayer.c              | 4 ++++
 libvlc/src/org/videolan/libvlc/MediaPlayer.java | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libvlc/jni/libvlcjni-mediaplayer.c b/libvlc/jni/libvlcjni-mediaplayer.c
index 8bf07a5..689fa48 100644
--- a/libvlc/jni/libvlcjni-mediaplayer.c
+++ b/libvlc/jni/libvlcjni-mediaplayer.c
@@ -30,6 +30,7 @@ JNIEnv *jni_get_env(const char *name);
 static const libvlc_event_type_t mp_events[] = {
     libvlc_MediaPlayerMediaChanged,
     libvlc_MediaPlayerOpening,
+    libvlc_MediaPlayerBuffering,
     libvlc_MediaPlayerPlaying,
     libvlc_MediaPlayerPaused,
     libvlc_MediaPlayerStopped,
@@ -75,6 +76,9 @@ MediaPlayer_event_cb(vlcjni_object *p_obj, const libvlc_event_t *p_ev,
 {
     switch (p_ev->type)
     {
+        case libvlc_MediaPlayerBuffering:
+            p_java_event->arg2 = p_ev->u.media_player_buffering.new_cache;
+            break;
         case libvlc_MediaPlayerPositionChanged:
             p_java_event->arg2 = p_ev->u.media_player_position_changed.new_position;
             break;
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index d8e92b6..ed4bd5b 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -29,7 +29,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
         public static final int MediaChanged        = 0x100;
         //public static final int NothingSpecial      = 0x101;
         public static final int Opening             = 0x102;
-        //public static final int Buffering           = 0x103;
+        public static final int Buffering           = 0x103;
         public static final int Playing             = 0x104;
         public static final int Paused              = 0x105;
         public static final int Stopped             = 0x106;
@@ -78,6 +78,9 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
         public boolean getSeekable() {
             return arg1 != 0;
         }
+        public float getBuffering() {
+            return arg2;
+        }
     }
 
     public interface EventListener extends VLCEvent.Listener<MediaPlayer.Event> {}
@@ -811,6 +814,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
                 mVoutCount = 0;
                 notify();
             case Event.Opening:
+            case Event.Buffering:
+                return new Event(eventType, arg2);
             case Event.Playing:
             case Event.Paused:
                 return new Event(eventType);



More information about the Android mailing list