Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android VideoView MediaPlayer OnInfoListener - events not fired

this following source code snippet is given:

videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {

            mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                @Override
                public boolean onInfo(MediaPlayer mp, int what, int extra) {
                    if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END){
                        activity.dismissDialog(DialogID.DIALOG_LOADING);
                        return true;
                    } 
                    return false;
                }
            });
        }
    });

I am streaming HLS streams with Android 3.x+ devices and trying to hide a loading dialog once the buffering is completed. The video streaming works, but the info events are never fired.

Any ideas?

like image 813
Nabil Avatar asked Oct 14 '12 13:10

Nabil


2 Answers

I know its too late, But posting it for the users still seeking for the solution (This worked for me):

        progressDialog.show();
        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                    @Override
                    public boolean onInfo(MediaPlayer mp, int what, int extra) {
                        if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END){
                            progressDialog.dismiss();
                            return true;
                        } else if(what == MediaPlayer.MEDIA_INFO_BUFFERING_START){
                            progressDialog.show();
                        }
                        return false;
                    }
                });
                progressDialog.dismiss();
                videoView.start();
            }
        });
like image 107
Myth Avatar answered Nov 15 '22 21:11

Myth


You're right, the events are never fired. This is a known HLS bug that I don't think Google will fix.

This applies to the onInfo and the buffering events.

See https://code.google.com/p/android/issues/detail?id=42767 and https://code.google.com/p/googletv-issues/issues/detail?id=2

Sorry!

like image 21
Cade Daniel Avatar answered Nov 15 '22 19:11

Cade Daniel