<template>
<view>
</view>
</template>
<script>
var audio = uni.createInnerAudioContext();
audio.sessionCategory = 'ambient';
var str = 1;
export default {
data() {
return {
tempindex: 0,
}
},
onReady() {
this.eventAudio();
setTimeout(() => {
audio.src = 'https://peiyin.wozhiyi.com/tmp/20240407/0aaa572a0b563ad6b5870735f9f2a600.mp3';
audio.play();
}, 1000)
},
methods: {
eventAudio() {
audio.onPlay(() => {
console.log('onPlay', this.tempindex);
this.tempindex++;
})
}
}
}
</script>
<style>
</style>

- 发布:2024-04-07 15:55
- 更新:2024-04-08 15:59
- 阅读:207
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win 10
HBuilderX类型: 正式
HBuilderX版本号: 3.99
手机系统: iOS
手机系统版本号: iOS 16
手机厂商: 苹果
手机机型: iPhone X
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
在app中运行页面
在app中运行页面
预期结果:
只执行一次
只执行一次
实际结果:
执行两次
执行两次
bug描述:
页面准备完成监听音频事件,onPlay会重复执行
