a***@qq.com
a***@qq.com
  • 发布:2023-12-11 11:33
  • 更新:2023-12-11 14:26
  • 阅读:144

ios上音频在浏览过程中,会出现重叠,两段音频同时播放

分类:uni-app
2023-12-11 11:33 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

全局一个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>

要回复问题请先登录注册