BackgroundAudioManager.onTimeUpdate
2020-08-26 16:26 更新
解释:音频进度更新事件
方法参数
Function callback
示例
图片示例
代码示例
- 在 js 文件中
Page({
data: {
duration: '',
currentTime: ''
},
onLoad() {
let that = this;
const backgroundAudioManager = swan.getBackgroundAudioManager();
backgroundAudioManager.title = '演员';
backgroundAudioManager.epname = '演员';
backgroundAudioManager.singer = '薛之谦';
backgroundAudioManager.coverImgUrl = 'https://c.hiphotos.baidu.com/super/pic/item/8b13632762d0f703e34c0f6304fa513d2797c597.jpg';
// 歌词地址,基础库 3.170.2 开始支持
backgroundAudioManager.lrcURL = 'xxxxx'; // 仅为示例,非真实接口地址
backgroundAudioManager.onTimeUpdate(function(res) {
console.log('backgroundAudioManager.onTimeUpdate', res)
that.setData({
duration: res.duration,
currentTime: res.currentTime
})
});
this.backgroundAudioManager = backgroundAudioManager;
this.backgroundAudioManager.src = 'https://vd3.bdstatic.com/mda-ic7mxzt5cvz6f4y5/mda-ic7mxzt5cvz6f4y5.mp3';
this.backgroundAudioManager.play();
}
});
以上内容是否对您有帮助:
更多建议: