Android的VideoView MediaPlayer的OnInfoListener - 不触发的事件 [英] Android VideoView MediaPlayer OnInfoListener - events not fired

查看:7108
本文介绍了Android的VideoView MediaPlayer的OnInfoListener - 不触发的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这下面的源$ C ​​$ C段给出:

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

我流HLS流了Android 3.X +设备,并试图一旦缓冲完毕隐藏加载对话框。 视频流媒体工作,但信息的事件从来没有发射。

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.

任何想法?

推荐答案

没有完全确定,以什么OP是问,但这里有一些信息非常不合时宜位。

Not fully sure as to what the OP is asking, but here are some very untimely bits of information.

我不会依赖于prepared。我觉得这是不可靠的。

I wouldn't rely on onPrepared. I find it to be unreliable.

我发现两个最有用的信息为HLS通过在MediaPlayer流是视频的持续时间和所述视频的进度位置。您可以通过听进度更新获取这两种。

I have found the two most useful pieces of information for HLS streaming through the MediaPlayer are the duration of the video and the progress position of the video. You get both of these by listening to progress updates.

当该持续时间大于零,就知道该视频是真正prepared并且可以操纵(擦洗)。当进度位置发生变化,你知道该视频是做缓冲,并开始播放。这最后一项仅在视频播放过程中的工作。在MediaPlayer往往传递不准确的信息。

When the duration is greater than zero, you know the video is truly prepared and can be manipulate (scrub). When progress position changes, you know the video is done buffering and has commenced playback. This last item only works when the video is playing of course. The MediaPlayer tends to relay inaccurate information.

这些信息大多是准确的,通常可以依靠的是相当及时。这个及时性相同也可以不同。

These pieces of information are mostly accurate and can usually be relied upon to be "fairly" timely. This timeliness varies from device to device.

这篇关于Android的VideoView MediaPlayer的OnInfoListener - 不触发的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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