diff --git a/src/pages/app/features/settings/cleartmp/cleartmp.ux b/src/pages/app/features/settings/cleartmp/cleartmp.ux index 9677d84..2e79ac6 100644 --- a/src/pages/app/features/settings/cleartmp/cleartmp.ux +++ b/src/pages/app/features/settings/cleartmp/cleartmp.ux @@ -87,17 +87,18 @@ export default { if (this.clearControl.sc) { const contents = await global.savedcontent.SavedContentManager.listAllContent() - contents.forEach((ct) => { - tasks.push(global.savedcontent.SavedContentManager.deleteContent(ct.id)) - }) + for (const ct of contents) { + await global.savedcontent.SavedContentManager.deleteContent(ct.id) + } } if (this.clearControl.videoAudio) { const contents = await global.savedcontent.SavedContentManager.listAllContent() const videoAudioContents = contents.filter((ct) => ct.type === 'videoAudio') - videoAudioContents.forEach((ct) => { - tasks.push(global.savedcontent.SavedContentManager.deleteContent(ct.id)) - }) + for (let i = 0; i < videoAudioContents.length; i++) { + const ct = videoAudioContents[i] + await global.savedcontent.SavedContentManager.deleteContent(ct.id) + } } await Promise.all(tasks) diff --git a/src/pages/video/player/player.ux b/src/pages/video/player/player.ux index a180f99..1facd3a 100644 --- a/src/pages/video/player/player.ux +++ b/src/pages/video/player/player.ux @@ -257,6 +257,25 @@ audio.pause(); } }; + audio.onctrlplay = () => { + if (!this.playerState.isPlaying) { + this.playerState.isPlaying = true; + this.isPlaying = true; + if (this.playTimeoutId) { + clearTimeout(this.playTimeoutId); + this.playTimeoutId = null; + } + audio.play(); + this.pendingSongId = null; + } + }; + audio.onctrlpause = () => { + if (this.playerState.isPlaying) { + this.playerState.isPlaying = false; + this.isPlaying = false; + audio.pause(); + } + }; audio.onstop = () => { this.playerState.isPlaying = false; this.isPlaying = false; @@ -690,11 +709,26 @@ audio.src = that.currSong.url; setTimeout(function() { if (!that.audioReady && that.isPlaying !== true) { - that.duration = audio.duration || 0; - that.audioReady = true; - that.isPlaying = true; - that.playerState.isPlaying = true; - audio.play(); + const dur = audio.duration; + if (dur && dur > 0 && !isNaN(dur)) { + that.duration = dur; + that.audioReady = true; + that.isPlaying = true; + that.playerState.isPlaying = true; + audio.play(); + } else { + console.log('音频时长无效,等待重试'); + setTimeout(function() { + if (!that.audioReady && that.isPlaying !== true) { + const dur2 = audio.duration; + that.duration = dur2 || 0; + that.audioReady = true; + that.isPlaying = true; + that.playerState.isPlaying = true; + audio.play(); + } + }, 500); + } } }, 500); } else { @@ -721,11 +755,26 @@ audio.src = that.currSong.url; setTimeout(function() { if (!that.audioReady && that.isPlaying !== true) { - that.duration = audio.duration || 0; - that.audioReady = true; - that.isPlaying = true; - that.playerState.isPlaying = true; - audio.play(); + const dur = audio.duration; + if (dur && dur > 0 && !isNaN(dur)) { + that.duration = dur; + that.audioReady = true; + that.isPlaying = true; + that.playerState.isPlaying = true; + audio.play(); + } else { + console.log('视频音频时长无效,等待重试'); + setTimeout(function() { + if (!that.audioReady && that.isPlaying !== true) { + const dur2 = audio.duration; + that.duration = dur2 || 0; + that.audioReady = true; + that.isPlaying = true; + that.playerState.isPlaying = true; + audio.play(); + } + }, 500); + } } }, 500); return; @@ -936,7 +985,9 @@ that.toastLog('校验成功,准备播放'); that.currSong.url = result.uri; that.saveVideoAudioToSavedContent(result.uri); - that.playCurrentSong(); + setTimeout(() => { + that.playCurrentSong(); + }, 300); }).catch((error) => { that.toastLog('校验异常,回退直链'); that.currSong.url = audioUrl; @@ -992,7 +1043,9 @@ } that.currSong.url = result.uri; that.saveVideoAudioToSavedContent(result.uri); - that.playCurrentSong(); + setTimeout(() => { + that.playCurrentSong(); + }, 300); }).catch((error) => { that.toastLog('校验异常,回退直链'); that.currSong.url = audioUrl; diff --git a/src/savedcontent.ts b/src/savedcontent.ts index e79f3b4..96845a9 100644 --- a/src/savedcontent.ts +++ b/src/savedcontent.ts @@ -128,7 +128,7 @@ export class SavedContentManager { // 读取所有存储内容的 id 和 title 列表 static async listAllContent(): Promise { - return storageIndex; + return [...storageIndex]; } // 删除内容