[Android] [PATCH 3/5] Handled MediaPlayerTimeChanged event.

Paulo Vitor Magacho da Silva pvmagacho at gmail.com
Fri Jul 25 04:14:31 CEST 2014


---
 vlc-android/jni/libvlcjni.c                           | 11 ++++++++---
 vlc-android/src/org/videolan/libvlc/EventHandler.java |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index af61f22..6a08d85 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -137,9 +137,13 @@ static void vlc_event_callback(const libvlc_event_t *ev, void *data)
     jmethodID putString = (*env)->GetMethodID(env, clsBundle, "putString", "(Ljava/lang/String;Ljava/lang/String;)V" );
 
     if (ev->type == libvlc_MediaPlayerPositionChanged) {
-            jstring sData = (*env)->NewStringUTF(env, "data");
-            (*env)->CallVoidMethod(env, bundle, putFloat, sData, ev->u.media_player_position_changed.new_position);
-            (*env)->DeleteLocalRef(env, sData);
+        jstring sData = (*env)->NewStringUTF(env, "data");
+        (*env)->CallVoidMethod(env, bundle, putFloat, sData, ev->u.media_player_position_changed.new_position);
+        (*env)->DeleteLocalRef(env, sData);
+    } else if (ev->type == libvlc_MediaPlayerTimeChanged) {
+        jstring sData = (*env)->NewStringUTF(env, "data");
+        (*env)->CallVoidMethod(env, bundle, putInt, sData, (int) ev->u.media_player_time_changed.new_time);
+        (*env)->DeleteLocalRef(env, sData);
     } else if(ev->type == libvlc_MediaPlayerVout) {
         /* For determining the vout/ES track change */
         jstring sData = (*env)->NewStringUTF(env, "data");
@@ -381,6 +385,7 @@ void Java_org_videolan_libvlc_LibVLC_playMRL(JNIEnv *env, jobject thiz, jlong in
         libvlc_MediaPlayerStopped,
         libvlc_MediaPlayerVout,
         libvlc_MediaPlayerPositionChanged,
+        libvlc_MediaPlayerTimeChanged,
         libvlc_MediaPlayerEncounteredError
     };
     for(int i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); i++)
diff --git a/vlc-android/src/org/videolan/libvlc/EventHandler.java b/vlc-android/src/org/videolan/libvlc/EventHandler.java
index 5c365a6..5a61fed 100644
--- a/vlc-android/src/org/videolan/libvlc/EventHandler.java
+++ b/vlc-android/src/org/videolan/libvlc/EventHandler.java
@@ -50,7 +50,7 @@ public class EventHandler {
     //public static final int MediaPlayerBackward             = 0x108;
     public static final int MediaPlayerEndReached             = 0x109;
     public static final int MediaPlayerEncounteredError       = 0x10a;
-    //public static final int MediaPlayerTimeChanged          = 0x10b;
+    public static final int MediaPlayerTimeChanged          = 0x10b;
     public static final int MediaPlayerPositionChanged        = 0x10c;
     //public static final int MediaPlayerSeekableChanged      = 0x10d;
     //public static final int MediaPlayerPausableChanged      = 0x10e;
-- 
1.8.5.2 (Apple Git-48)



More information about the Android mailing list