请问大家有没有遇到这种问题呢?
我即使按照官方示例,把code直接复制粘贴到我的开发者工具里,也是无法切换音频的播放速度。
示例如下:
示例代码:
action的method属性只能是play
、pause
、setPlaybackRate
、setCurrentTime
,用法如下:
<!-- 循环播放 --><audio poster="{{poster}}" name="{{name}}" author="{{author}}" src="{{src}}" action="{{action}}" controls loop></audio><button type="primary" bindtap="audioPlay">播放</button><button type="primary" bindtap="audioPause">暂停</button><button type="primary" bindtap="audioPlaybackRateSpeedUp">调为2倍速</button><button type="primary" bindtap="audioPlaybackRateNormal">调为1倍速</button><button type="primary" bindtap="audioPlaybackRateSlowDown">调为0.5倍速</button><button type="primary" bindtap="audio14">设置当前播放时间为14秒</button><button type="primary" bindtap="audioStart">回到开头</button>
// app-servicePage({
data: {
poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
name: '此时此刻',
author: '许巍',
src: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46',
},
audioPlay: function () { this.setData({
action: {
method: 'play'
}
})
},
audioPause: function () { this.setData({
action: {
method: 'pause'
}
})
},
audioPlaybackRateSpeedUp: function () { this.setData({
action: {
method: 'setPlaybackRate',
data: 2
}
})
},
audioPlaybackRateNormal: function () { this.setData({
action: {
method: 'setPlaybackRate',
data: 1
}
})
},
audioPlaybackRateSlowDown: function () { this.setData({
action: {
method: 'setPlaybackRate',
data: 0.5
}
})
},
audio14: function () { this.setData({
action: {
method: 'setCurrentTime',
data: 14
}
})
},
audioStart: function () { this.setData({
action: {
method: 'setCurrentTime',
data: 0
}
})
}
})
谢谢!