小程序音频长度显示到页面的案例代码:
使用开发者工具,在对应页面的js文件中添加:
audioPlayed: function () {myAudio.play()setTimeout(() => {myAudio.currentTimemyAudio.onTimeUpdate(() => {console.log(myAudio.duration) //总时长console.log(myAudio.currentTime) //当前播放进度})}, 500)}
audioPlayed: function () {
myAudio.play()
setTimeout(() => {
myAudio.currentTime
myAudio.onTimeUpdate(() => {
console.log(myAudio.duration) //总时长
console.log(myAudio.currentTime) //当前播放进度
})
}, 500)
}