我正在制作一个城市网络摄像头应用程序,它使用libVlc来显示来自城市网络摄像头的rtsp流。我的问题是,有可能获得流的实际加载状态吗?我想向用户展示。我可以在Android Studio runLog中看到有某种缓冲但在代码中找不到。
D/VLC: core input: Buffering 56%
D/VLC: core input: Buffering 58%
D/VLC: core input: Buffering 61%
D/VLC: core input: Buffering 64%
D/VLC: core input: Buffering 66%
D/VLC: core input: Buffering 69%
D/VLC: core input: Buffering 72%
D/VLC: core input: Buffering 72%
D/VLC: core input: Buffering 77%
答案 0 :(得分:2)
这是libvlc:2.1.1
。你可以使用类似的东西获得缓冲百分比 - >
MediaPlayer.EventListener
。mMediaPlayer.setEventListener(this);
onEvent
方法在该方法中,您可以使用event.getBuffering()
:
@Override
public void onEvent(MediaPlayer.Event event) {
switch(event.type) {
case MediaPlayer.Event.Buffering:
Log.d("BUFFERING", ""+event.getBuffering());
break;
}
}
答案 1 :(得分:1)
您应该附加到libvlc_MediaPlayerBuffering
事件。
答案 2 :(得分:1)
我添加了这个版本的vlc android sdk
编译'de.mrmaffen:vlc-android-sdk:2.0.6'
private static class MyPlayerListener implements MediaPlayer.EventListener {
private WeakReference<VlcPlayerActivity> mOwner;
public MyPlayerListener(VlcPlayerActivity owner) {
mOwner = new WeakReference<VlcPlayerActivity>(owner);
}
@Override
public void onEvent(MediaPlayer.Event event) {
VlcPlayerActivity player = mOwner.get();
switch (event.type) {
case MediaPlayer.Event.Buffering:
Log.d(TAG, ""+event.getBuffering());
break;
case MediaPlayer.Event.EndReached:
Log.d(TAG, "MediaPlayerEndReached");
player.releasePlayer();
break;
case MediaPlayer.Event.Playing:
case MediaPlayer.Event.Paused:
case MediaPlayer.Event.Stopped:
default:
break;
}
}
}