innerAudioContext.onCanplay(() => {
innerAudioContext.duration
let getAudioTime = setInterval(() => {
console.log('定时器获取duration', innerAudioContext.duration)
if (innerAudioContext.duration !== 0) { // 里面有时间了
let audioEndTime = Math.floor(innerAudioContext.duration)
console.log('获取音频总时长为-------》', audioEndTime)
clearInterval(getAudioTime)
}
}, 1000)
})
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
(https://developers.weixin.qq.com/community/develop/doc/000c80f02e45a05a50794147956c00?_at=1634641471284)