Iphone 6s plus 微信版本8.0.15【最新版本了】基础库版本2.33.0
<audio poster="{{poster}}" name="{{name}}" author="{{author}}" src="{{src}}" id="myAudio" controls loop></audio>
<button type="primary" bindtap="audioPlay">播放</button>
<button type="primary" bindtap="audioPause">暂停</button>
<button type="primary" bindtap="audio14">设置当前播放时间为14秒</button>
<button type="primary" bindtap="audioStart">回到开头</button>
------------------------
Page({
onReady: function (e) {
wx.setInnerAudioOption({
obeyMuteSwitch: false,
success: e => {
console.log("sussess: " + e.errMsg);
},
fail: e => {
console.log("error: " + e.errMsg)
}
})
this.audioContext = wx.createInnerAudioContext({
useWebAudioImplement: true,
})
this.audioContext.src = this.data.src;
// 使用 wx.createAudioContext 获取 audio 上下文 context
// this.audioCtx = wx.createAudioContext('myAudio')
},
data: {
poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
name: '此时此刻',
author: '许巍',
src: 'https://ltssimg.ershengsan.cn/405e24e867384e28a8ce3683d9f82ba4.mp3',
},
audioPlay: function () {
this.audioContext.play();
// this.audioCtx.play()
},
audioPause: function () {
this.audioContext.pause();
// this.audioCtx.pause()
},
audio14: function () {
this.audioContext.seek(14);
// this.audioCtx.seek(14)
},
audioStart: function () {
this.audioContext.seek(0);
// this.audioCtx.seek(0)
}
})