返回游戏时添加声音加载

This commit is contained in:
kron
2026-01-06 18:13:55 +08:00
parent ab3537e35d
commit 7cb203a08f
4 changed files with 33 additions and 15 deletions

View File

@@ -132,6 +132,7 @@ class AudioManager {
this.localFileCache = uni.getStorageSync("audio_local_files") || {};
// 启动时自动清理过期的缓存文件URL 已不在 audioFils 中的文件)
this.cleanObsoleteCache();
this.initAudios();
}
@@ -374,7 +375,6 @@ class AudioManager {
debugLog(`命中本地缓存: ${key}`);
setupAudio(localPath);
} else {
console.log("download");
// 下载并尝试保存
uni.downloadFile({
url: src,
@@ -382,7 +382,7 @@ class AudioManager {
success: (res) => {
if (res.tempFilePath) {
// 尝试保存文件到本地存储(持久化)
uni.saveFile({
uni.getFileSystemManager().saveFile({
tempFilePath: res.tempFilePath,
success: (saveRes) => {
const savedPath = saveRes.savedFilePath;