例如密码输入框的音频
//输入框密码长度变化
ischange(e) {
this.initialisePassword()
this.passwordContexts['ber'].play()
this.passwordContexts['ber'].onPlay(() => {
console.log('开始播放')
})
this.passwordContexts['ber'].onEnded(() => {
this.passwordContexts['ber'].destroy()
})
this.passwordContexts['ber'].onError((res) => {
console.log(res, 'yinpin')
})
},
//输入密码的音频
initialisePassword() {
if (this.passwordContexts['ber']) {
this.passwordContexts['ber'].destroy();
}
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = false; // 禁自动播放
innerAudioContext.src = '/static/sounds/ber.mp3';
innerAudioContext.sessionCategory = 'ambient';
this.passwordContexts['ber'] = innerAudioContext
},
1 个回复
2***@qq.com
解决了么 我也遇到了