.wxml:
{ {now_time?now_time:'00:00'}} { {AudioDetail.audio_length}}
.js:
const innerAudioContext = wx.createInnerAudioContext();//创建音频容器Page({ /*** 页面的初始数据*/ data: { slider_value: 0//设置初始滑块位置为0 }, /*** 生命周期函数--监听页面加载*/ onLoad: function (options) { this.setData({ slider_value: 0, now_time: 0 }); innerAudioContext.seek(0);//设置音频初始位置为0 this.getAudioDetail();//获取一品 this.audioListen(); }, /*** 生命周期函数--监听页面卸载*/ onUnload: function () { innerAudioContext.pause();//退出页面时,暂停音频 },
/*** 监听slider*/ listenerSlider: function (e) { //获取滑动后的值 console.log(e.detail.value); var per = e.detail.value / 100; var long = per * this.data.audio_length; this.setData({