Question

I would like to subscribe for the MediaPlayer buffering event in the android vlc app.

I edited the EventHandler class and uncommented the event constant.

public static final int MediaPlayerBuffering            = 0x103; // ** uncommented this**
public static final int MediaPlayerPlaying                = 0x104;

I then added the the variable in libvlcjni.c

libvlc_event_manager_t *ev = libvlc_media_player_event_manager(mp);
static const libvlc_event_type_t mp_events[] = {
    libvlc_MediaPlayerPlaying,
    libvlc_MediaPlayerPaused,
    libvlc_MediaPlayerEndReached,
    libvlc_MediaPlayerStopped,
    libvlc_MediaPlayerVout,
    libvlc_MediaPlayerPositionChanged,
    libvlc_MediaPlayerEncounteredError,
    libvlc_MediaPlayerBuffering // **added this here**
};

recompiled the jni to get the so file and then built the vlc app but the event never seems to fire off.

Where else do I have to link to get the event fired when there is a buffering event due to lack of bandwidth.

I can see in logcat that it prints 1001 ms buffered in 6ms. But that is coming from the lower layer and not the java layer

Était-ce utile?

La solution

had to add this in the libvlcjni.c file

else if(ev->type == libvlc_MediaPlayeBuffering) {
    /* For determining the vout/ES track change */
    jstring sData = (*env)->NewStringUTF(env, "data");
    (*env)->CallVoidMethod(env, bundle, putFloat, sData, ev->u.media_player_buffer.new_cache);
    (*env)->DeleteLocalRef(env, sData);
}

hope this helps someone

Autres conseils

else if(ev->type == libvlc_MediaPlayerBuffering) { /* For determining the vout/ES track change */ jstring sData = (*env)->NewStringUTF(env, "data"); (*env)->CallVoidMethod(env, bundle, putFloat, sData, ev->u.media_player_buffering.new_cache); (*env)->DeleteLocalRef(env, sData); }

The answer is ev->u.media_player_buffering.new_cache

In the VLC file mediaPlayer.c I found this code:

`else if( newval.i_int == INPUT_EVENT_CACHE )
   {
    event.type = libvlc_MediaPlayerBuffering;
    event.u.media_player_buffering.new_cache = (int)(100 * var_GetFloat( p_input, "cache" ));
    libvlc_event_send( p_mi->p_event_manager, &event );
}

`

and in libvlc_events.h

/* media instance */ struct { float new_cache; } media_player_buffering;

Then, I compiled it and it worked. Special thanks to my boy Tracy on the coast!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top