首先频率有问题:
https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=00006e5976cf9866f726a217b51800&highline=video%7C%26%E7%BB%84%E4%BB%B6%7C%26%E7%9A%84%7C%26bindtimeupdate&token=905838030&lang=zh_CN
但是精度有问题,模拟器上出来是是浮点数,设备上(iOS,Android)都是整数:
代码如下:
onStartPlay () { this .startWallClcokInSec = new Date().getTime() / 1000 this .lastVideoTimeInSec = 0.0 }, onTimeUpdate (e) { var currentWallClockInSec = new Date().getTime() / 1000 var currentVideoTimeInSec = e.mp.detail.currentTime var wallClock = currentWallClockInSec - this .startWallClcokInSec console.log(`wallclock:${(wallClock).toFixed(3)}, videoTime: ${(currentVideoTimeInSec).toFixed(3)}`) } |
模拟器输出:
wallclock:1.247, videoTime: 1.098 wallclock:1.747, videoTime: 1.598 wallclock:1.997, videoTime: 1.848 wallclock:2.248, videoTime: 2.098 wallclock:2.747, videoTime: 2.598 wallclock:3.247, videoTime: 3.098 wallclock:3.747, videoTime: 3.598 wallclock:3.997, videoTime: 3.848 |
iOS输出:
wallclock:0.232, videoTime: 0.000 wallclock:0.234, videoTime: 0.000 wallclock:1.235, videoTime: 1.000 wallclock:2.251, videoTime: 2.000 wallclock:3.237, videoTime: 3.000 wallclock:4.241, videoTime: 4.000 wallclock:4.875, videoTime: 4.000 |
bindtimeupdate参数:(貌似进来只是个整数?)
JSON.stringify(e, null, 2):
"{ "mp": { "type": "timeupdate", "target": { "dataset": { "eventid": "0" }, "id": "", "offsetTop": 0, "offsetLeft": 0 }, "currentTarget": { "dataset": { "eventid": "0" }, "id": "", "offsetTop": 0, "offsetLeft": 0 }, "timeStamp": 78938, "detail": { "currentTime": 4, "duration": 4.63 } }, "type": "timeupdate", "timeStamp": 78938, "target": { "dataset": { "eventid": "0" }, "id": "", "offsetTop": 0, "offsetLeft": 0, "currentTime": 4, "duration": 4.63 }, "currentTarget": { "dataset": { "eventid": "0" }, "id": "", "offsetTop": 0, "offsetLeft": 0 } }"
|
设备信息:
{"errMsg":"getSystemInfo:ok","batteryLevel":95,"version":"6.6.6","system":"iOS 11.3","windowHeight":603,"pixelRatio":2,"screenHeight":667,"language":"zh_CN","statusBarHeight":20,"windowWidth":375,"model":"iPhone 7<iPhone9,1>","screenWidth":375,"fontSizeSetting":16,"brand":"iPhone","platform":"ios","SDKVersion":"1.9.98"}
你好,请问是什么场景需要获取毫秒级的video的时间?
bindtimeupdate 说是250ms触发一次,iOS上是1秒触发一次,android 没测试不知道。我做字幕同步,需要根据这个时间来处理。
楼主我也遇到同样的问题请问有解决方案吗?
我们有个场景是这样的,一段音频需要跟读,我们设置了一些断点来暂停播放器,暂停后用户跟读,暂停一段时间后,系统自动继续播下一段。
现在onTimeUpdate触发间隔大概是0.25秒,这个时间精度不够,经常超过我们设置的暂停点。
通过bindtimeupdate来得到currentTime,进而得到进度条的位置,这个方案不能满足么?
@cunjinli 未来会支持么
现在还不支持这个功能,可以考虑通过bindtimeupdate来得到currentTime,进而得到进度条的位置
@cunjinli 还有想请问下,怎么监听到video的进度条的拖动,想根据这个来做业务处理。
所以这是没人管的意思么……
毫秒级的时间有方法能取到么?
另外,在Android上面“duration”也是就近取整……