微信小程序编译
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { uid } from '../utils';
|
||||
import { isSupportCacheAudio } from '../../check-version';
|
||||
import { WEBAudio, audios } from './store';
|
||||
import { TEMP_DIR_PATH } from './const';
|
||||
export const resumeWebAudio = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
WEBAudio.audioContext?.resume();
|
||||
GameGlobal.Module.mContext?.resume();
|
||||
GameGlobal.Module.context?.resume();
|
||||
};
|
||||
export const createInnerAudio = () => {
|
||||
const id = uid();
|
||||
const audio = (isSupportCacheAudio && WEBAudio.audioCache.length ? WEBAudio.audioCache.shift() : wx.createInnerAudioContext());
|
||||
if (audio) {
|
||||
audios[id] = audio;
|
||||
}
|
||||
return {
|
||||
id,
|
||||
audio,
|
||||
};
|
||||
};
|
||||
export const destroyInnerAudio = (id, useCache) => {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
if (!useCache || !isSupportCacheAudio || WEBAudio.audioCache.length > 32) {
|
||||
audios[id].destroy();
|
||||
}
|
||||
else {
|
||||
|
||||
['Play', 'Pause', 'Stop', 'Canplay', 'Error', 'Ended', 'Waiting', 'Seeking', 'Seeked', 'TimeUpdate'].forEach((eventName) => {
|
||||
audios[id][`off${eventName}`]();
|
||||
});
|
||||
const state = {
|
||||
startTime: 0,
|
||||
obeyMuteSwitch: true,
|
||||
volume: 1,
|
||||
autoplay: false,
|
||||
loop: false,
|
||||
referrerPolicy: '',
|
||||
};
|
||||
Object.keys(state).forEach((key) => {
|
||||
try {
|
||||
|
||||
// @ts-ignore
|
||||
audios[id][key] = state[key];
|
||||
}
|
||||
catch (e) { }
|
||||
});
|
||||
audios[id].stop();
|
||||
const cacheAudio = audios[id];
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
WEBAudio.audioCache.push(cacheAudio);
|
||||
}, 1000);
|
||||
}
|
||||
delete audios[id];
|
||||
};
|
||||
export const printErrMsg = (msg) => {
|
||||
GameGlobal.manager.printErr(msg);
|
||||
};
|
||||
export function mkCacheDir() {
|
||||
const fs = wx.getFileSystemManager();
|
||||
fs.rmdir({
|
||||
dirPath: TEMP_DIR_PATH,
|
||||
recursive: true,
|
||||
complete: () => {
|
||||
fs.mkdir({
|
||||
dirPath: TEMP_DIR_PATH,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user