返回游戏时添加声音加载
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user