gpt4 book ai didi

android - VideoView seekto() 函数极其不一致

转载 作者:IT老高 更新时间:2023-10-28 22:18:54 27 4
gpt4 key购买 nike

我正在尝试寻找 Android 视频中的特定位置,但由于其行为表现出不一致,我完全被卡住了。这是我做过的事情的 list

  1. VideoView.Seekto goes to 5:19 for one video, 5:17 for one video and 5:32 for another for the same milliseconds(326000 ms)!
  2. Since VideoView does not support onSeekListener, I've modified the source VideoView and added support for it. Yet it does not pause and start seeking from where I want it to - there is always a lag! The onSeekListener is called immediately some 6 s before where I want it to stop. In many cases the seek bar shows the right time and suddenly jumps back a few seconds even though I am calling video.start from onSeekCompleteListener

为什么会如此不一致?在视频 View 中是否有明确的方法可以在几毫秒内找到您想去的地方?我知道我应该使用 MediaPLayer + Surface 但由于 VideoView 只是两者的包装,我在源代码处对其进行了修改但无济于事。

我知道这一点:http://code.google.com/p/android/issues/detail?id=9135但是有什么办法可以解决这个问题并有明确的方法

1.) Seeking to the exact time in milliseconds

2.) Pausing and resuming at the exact time?

最佳答案

您必须等待搜索完成。

VideoView 没有 OnSeekCompleteListener(),但您可以从 VideoView 的 onPrepared 方法访问 MediaPlayer,然后设置 OnSeekCompleteListener,如下所示:

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

mp.setOnSeekCompleteListener(new OnSeekCompleteListener() {
@Override
public void onSeekComplete(MediaPlayer mp) {
//Seek completed. Move seekbar
}
});

}
});

关于android - VideoView seekto() 函数极其不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12939159/

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