videoview seekto()

shililang 2013-09-26 02:24:11
用seekto()改变视频播放进度,但好像不准确,比如我要seek到10秒处(片子得到的duration是61068,我seekto(10000)),结果它在12秒的地方播放;我seekto(duration),应该是结束的,但还放了一秒的样子才结束。帮小弟分析下这是怎么个回事啊!
...全文
289 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shililang 2013-09-26
  • 打赏
  • 举报
回复
引用 3 楼 tantahe 的回复:
[quote=引用 2 楼 shililang 的回复:] [quote=引用 1 楼 tantahe 的回复:] seekTo(int)是异步的,马上就返回了,真正的seek操作可能需要一点时间才能完成。 我理解你在10s的时候seekTo,视频跳到了10s,开始做准备工作,但是12s的时候才准备好,然后开始播放。 SDKstackoverflow都有这段说明:
The playback position can be adjusted with a call to seekTo(int).
Although the asynchronuous seekTo(int) call returns right way, the actual seek operation may take a while to finish, especially for audio/video being streamed. When the actual seek operation completes, the internal player engine calls a user supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener has been registered beforehand via setOnSeekCompleteListener(OnSeekCompleteListener).
恩,看了下,应该就是这个原因了,貌似没解决方法。。[/quote] 可以试试自己加入一个提前量,比方你想跳到10s,你代码里设置跳到8s,提前量可以自行调整,这样能减小误差。[/quote]恩,这也是一种方法,谢啦,结贴了!
tantahe 2013-09-26
  • 打赏
  • 举报
回复
引用 2 楼 shililang 的回复:
[quote=引用 1 楼 tantahe 的回复:] seekTo(int)是异步的,马上就返回了,真正的seek操作可能需要一点时间才能完成。 我理解你在10s的时候seekTo,视频跳到了10s,开始做准备工作,但是12s的时候才准备好,然后开始播放。 SDKstackoverflow都有这段说明:
The playback position can be adjusted with a call to seekTo(int).
Although the asynchronuous seekTo(int) call returns right way, the actual seek operation may take a while to finish, especially for audio/video being streamed. When the actual seek operation completes, the internal player engine calls a user supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener has been registered beforehand via setOnSeekCompleteListener(OnSeekCompleteListener).
恩,看了下,应该就是这个原因了,貌似没解决方法。。[/quote] 可以试试自己加入一个提前量,比方你想跳到10s,你代码里设置跳到8s,提前量可以自行调整,这样能减小误差。
shililang 2013-09-26
  • 打赏
  • 举报
回复
引用 1 楼 tantahe 的回复:
seekTo(int)是异步的,马上就返回了,真正的seek操作可能需要一点时间才能完成。 我理解你在10s的时候seekTo,视频跳到了10s,开始做准备工作,但是12s的时候才准备好,然后开始播放。 SDKstackoverflow都有这段说明:
The playback position can be adjusted with a call to seekTo(int).
Although the asynchronuous seekTo(int) call returns right way, the actual seek operation may take a while to finish, especially for audio/video being streamed. When the actual seek operation completes, the internal player engine calls a user supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener has been registered beforehand via setOnSeekCompleteListener(OnSeekCompleteListener).
恩,看了下,应该就是这个原因了,貌似没解决方法。。
tantahe 2013-09-26
  • 打赏
  • 举报
回复
seekTo(int)是异步的,马上就返回了,真正的seek操作可能需要一点时间才能完成。 我理解你在10s的时候seekTo,视频跳到了10s,开始做准备工作,但是12s的时候才准备好,然后开始播放。 SDKstackoverflow都有这段说明:
The playback position can be adjusted with a call to seekTo(int).
Although the asynchronuous seekTo(int) call returns right way, the actual seek operation may take a while to finish, especially for audio/video being streamed. When the actual seek operation completes, the internal player engine calls a user supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener has been registered beforehand via setOnSeekCompleteListener(OnSeekCompleteListener).

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧