I want to monitor the switching between differnt bitrates on a HLS stream in Android. So i was thinking to monitor the HLS chunk requests. and parse these. Do you guys have any idea how i would go around and do this?
I have already tried monitoring the on videosizechanged but i do not think this will suffice...
vv.setVideoPath("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
vv.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaPlayer = mp;
mMediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
Log.e(TAG, "perhaps changed bitrate?");
}
});
}
});
vv.start();
Any ideas are more than welcome.
Unfortunately, it is not possible to do with android.media.MediaPlayer API. In the callback onVideoSizeChanged() there is no news about it. You can be lucky checking the callback android.media.MediaPlayer.OnInfoListener with the event MEDIA_INFO_BUFFERING_START and his extra, but the behaviour changes according to the manufacturer.
My suggestion is to switch to the new ExoPlayer, an open source project powered by Google. In the last release, it handles HLS. Through the class HlsChunkSource, you can retrieve information about all chunk request ( for instance by the method getChunkOperation() ).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With