在android vlc中启用MediaPlayerBuffering事件
我想订阅android vlc应用程序中的MediaPlayer缓冲事件 我编辑了EventHandler类并取消了对事件常量的注释在android vlc中启用MediaPlayerBuffering事件,android,vlc,libvlc,Android,Vlc,Libvlc,我想订阅android vlc应用程序中的MediaPlayer缓冲事件 我编辑了EventHandler类并取消了对事件常量的注释 public static final int MediaPlayerBuffering = 0x103; // ** uncommented this** public static final int MediaPlayerPlaying = 0x104; 然后,我将变量添加到libvlcjni.c中 li
public static final int MediaPlayerBuffering = 0x103; // ** uncommented this**
public static final int MediaPlayerPlaying = 0x104;
然后,我将变量添加到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**
};
重新编译jni以获取so文件,然后构建vlc应用程序,但事件似乎从未触发
当由于缺少带宽而发生缓冲事件时,我还必须链接到哪里才能触发事件
我可以在logcat中看到,它打印1001毫秒,缓冲时间为6毫秒。但是它来自底层,而不是java层,必须将它添加到libvlcjni.c文件中
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);
}
如果(ev->type==libvlc\u MediaPlayerBuffering),希望这对其他人有帮助{
/*用于确定vout/ES轨道变化*/
jstringsdata=(*env)->NewStringUTF(env,“数据”);
(*env)->CallVoidMethod(env、bundle、putFloat、sData、ev->u.media\u player\u buffering.new\u cache);
(*env)->DeleteLocalRef(env,sData);
}
答案是ev->u.media\u player\u buffering.new\u cache
在VLC文件mediaPlayer.c中
我发现这个代码:
`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 );
}
`
在libvlc_事件中
/*媒体实例*/
结构
{
浮动新缓存;
}媒体播放器缓冲;
然后,我编译了它,它成功了。特别感谢我在海边的儿子特蕾西 您在libvlcjni文件中的何处实现了这一点?我收到一个错误“union”const“no member name”media\u player\u buffer”…很抱歉,我对JNI几乎没有经验。只需搜索事件类型,我现在不记得确切的位置。您可以找到else if块的列表。。只需将此事件植入更多:)