有没有办法让 LibVlc 加载缓冲区百分比? [英] Is there a way to get LibVlc loaded buffer percentage?

查看:52
本文介绍了有没有办法让 LibVlc 加载缓冲区百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我目前正在制作一个城市网络摄像头应用程序,它使用 libVlc 来显示来自城市网络摄像头的 rtsp 流.我的问题是,有可能获得流的实际加载状态吗?我想向用户展示.我可以在 Android Studio runLog 中看到有某种缓冲,但在代码中找不到.


I'm currently making a city webcam app which uses libVlc to display the rtsp stream coming from the city webcams. My question is, it is possible to get the actual loaded state of the stream? I would like to show to the user. I can see in Android Studio runLog that there is some kind of buffering but cannot find in the code.

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%

推荐答案

This is for libvlc:2.1.1.你可以使用这样的东西来获得缓冲百分比 ->

This is for libvlc:2.1.1. you can get the buffer percentage using something like this ->

  • 对您的视频播放器活动实施 MediaPlayer.EventListener.
  • 将您的媒体播放器事件侦听器附加到当前活动:mMediaPlayer.setEventListener(this);
  • 在您的活动中覆盖 onEvent 方法
  • 在该方法中,您可以使用 event.getBuffering() 获取缓冲区浮点数:

  • Implement MediaPlayer.EventListener on your video player activity.
  • Attach your media player event listener to current activity: mMediaPlayer.setEventListener(this);
  • Override onEvent method in your activity
  • In that method you can get the buffer float using event.getBuffering():

@Override
public void onEvent(MediaPlayer.Event event) {
    switch(event.type) {
        case MediaPlayer.Event.Buffering:
            Log.d("BUFFERING", ""+event.getBuffering());
            break;
    }
}

这篇关于有没有办法让 LibVlc 加载缓冲区百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆