Reputation: 896
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%
Upvotes: 3
Views: 2879
Reputation: 1529
I add this version of vlc android sdk
compile '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;
}
}
}
Upvotes: 1
Reputation: 421
This is for libvlc:2.1.1
. you can get the buffer percentage using something like this ->
MediaPlayer.EventListener
on your video player activity.mMediaPlayer.setEventListener(this);
onEvent
method in your activityIn 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;
}
}
Upvotes: 5