gpt4 book ai didi

Android VideoView MediaPlayer OnInfoListener - 事件未触发

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:51:10 25 4
gpt4 key购买 nike

给出了以下源代码 fragment :

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;
}
});
}
});

我正在使用 Android 3.x+ 设备流式传输 HLS 流,并尝试在缓冲完成后隐藏加载对话框。视频流有效,但永远不会触发信息事件。

有什么想法吗?

最佳答案

我知道为时已晚,但将其发布给仍在寻求解决方案的用户(这对我有用):

        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();
}
});

关于Android VideoView MediaPlayer OnInfoListener - 事件未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12882815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com