我目前正在制作一个城市网络摄像头应用程序,它使用 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%
这是为了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;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)