全局一个createInnerAudioContext,更换播放的MP3 链接,还有问题,可以上传附件
<template>
<view class="content">
<button @click="playAudio">playAudio</button>
<button @click="next">next</button>
<button @click="pause">pause</button>
</view>
</template>
<script>
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
export default {
components: {
},
data() {
return {
}
},
onLoad() {
},
methods: {
playAudio(){
innerAudioContext.src = 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3';
},
pause(){
innerAudioContext.stop()
},
next(){
innerAudioContext.src = 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3';
}
}
}
</script>
<style>
</style>
1 个回复
喜欢技术的前端 - QQ---445849201
全局一个createInnerAudioContext,更换播放的MP3 链接,还有问题,可以上传附件