首先频率有问题:
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"}
谁来解释下,怎么获取毫秒级的时间。