- 发布:2023-11-14 19:21
- 更新:2023-11-14 20:03
- 阅读:325
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 3.96
手机系统: 全部
手机厂商: 苹果
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
startMIc() {
this.whiteAudio = uni.createInnerAudioContext();
this.woodAudio = uni.createInnerAudioContext();
let soundMic = uni.getStorageSync('micValue');
if (soundMic == '') {
console.log('内存没存值')
//初始化
let micValue = {
whiteNoise: '',
micMode: '',
woodMic: ''
};
let isMute = '../../static/noise/yichichunjiulv.mp3'; //初始白噪音路径
let isWood = '../../static/noise/moren.mp3';
micValue.micMode = 1;
micValue.whiteNoise = isMute;
micValue.woodMic = isWood;
this.whiteAudio.src = isMute;
this.woodAudio.src = isWood;
uni.setStorageSync('micValue', micValue);
} else {
this.whiteAudio.src = soundMic.whiteNoise;
this.woodAudio.src = soundMic.woodMic;
}
this.whiteAudio.loop = true;
if (uni.getSystemInfoSync().platform != "ios") {
this.whiteAudio._options.sessionCategory = "ambient";
this.woodAudio._options.sessionCategory = "ambient";
}
this.whiteAudio.autoplay = true;
this.whiteAudio.play();
//木鱼
this.woodAudio.loop = true;
this.woodAudio.autoplay = true;
this.woodAudio.play();
console.log(this.woodAudio)
},
startMIc() {
this.whiteAudio = uni.createInnerAudioContext();
this.woodAudio = uni.createInnerAudioContext();
let soundMic = uni.getStorageSync('micValue');
if (soundMic == '') {
console.log('内存没存值')
//初始化
let micValue = {
whiteNoise: '',
micMode: '',
woodMic: ''
};
let isMute = '../../static/noise/yichichunjiulv.mp3'; //初始白噪音路径
let isWood = '../../static/noise/moren.mp3';
micValue.micMode = 1;
micValue.whiteNoise = isMute;
micValue.woodMic = isWood;
this.whiteAudio.src = isMute;
this.woodAudio.src = isWood;
uni.setStorageSync('micValue', micValue);
} else {
this.whiteAudio.src = soundMic.whiteNoise;
this.woodAudio.src = soundMic.woodMic;
}
this.whiteAudio.loop = true;
if (uni.getSystemInfoSync().platform != "ios") {
this.whiteAudio._options.sessionCategory = "ambient";
this.woodAudio._options.sessionCategory = "ambient";
}
this.whiteAudio.autoplay = true;
this.whiteAudio.play();
//木鱼
this.woodAudio.loop = true;
this.woodAudio.autoplay = true;
this.woodAudio.play();
console.log(this.woodAudio)
},
操作步骤:
开始播放音乐,app内敲木鱼的声音30s重复一次,但是循环时中间会卡顿,导致敲木鱼节奏会变化,体验很差
开始播放音乐,app内敲木鱼的声音30s重复一次,但是循环时中间会卡顿,导致敲木鱼节奏会变化,体验很差
预期结果:
循环播放不卡顿
循环播放不卡顿
实际结果:
循环播放中间会卡顿
循环播放中间会卡顿
1 个回复
9***@qq.com (作者)
安卓下载链接:https://sj.qq.com/appdetail/com.dolphinflow.focus