Skip to content

Commit 92b9f12

Browse files
Dev cy 02 (#901)
* chore: 将 @electron/node-gyp 依赖从 git 协议更改为 https tarball 更新 pnpm-lock.yaml 中 @electron/node-gyp 包的解析方式,从 git+https 协议切换到 https tarball 链接,以提高依赖下载的可靠性和兼容性。 * refactor(store): 移除重复的状态属性并添加进度属性 移除 automixFxSeq 和 automixEndedSeq 的重复定义,这些属性已在初始状态中声明。 新增 progress 属性以支持播放进度跟踪。 * fix(音频播放器): 修复加载时暂停状态不一致的问题 在加载新音频源时,确保音频上下文和Web Worker的暂停状态同步。暂停运行中的音频上下文,并通知Worker暂停处理,避免加载过程中的音频播放异常。 * refactor(stores): 调整状态存储中字段顺序 将 automixFxSeq 和 automixEndedSeq 字段移至状态对象末尾,以改善代码组织结构和可读性。
1 parent fc80dab commit 92b9f12

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/core/audio-player/ffmpeg-engine/FFmpegAudioPlayer.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export class FFmpegAudioPlayer extends BaseAudioPlayer {
157157
this.dispatch("loadstart");
158158

159159
this.init();
160+
if (this.audioCtx && this.audioCtx.state === "running") {
161+
await this.audioCtx.suspend().catch(() => undefined);
162+
}
160163

161164
try {
162165
if (this.worker) {
@@ -186,6 +189,10 @@ export class FFmpegAudioPlayer extends BaseAudioPlayer {
186189
file: file,
187190
chunkSize: 4096 * 8,
188191
});
192+
this.isWorkerPaused = true;
193+
await this.requestWorker({ type: "PAUSE" }).catch(() => {
194+
this.isWorkerPaused = false;
195+
});
189196
} else {
190197
await this.loadSrc(url as string);
191198
}
@@ -233,6 +240,10 @@ export class FFmpegAudioPlayer extends BaseAudioPlayer {
233240

234241
this.runFetchLoop(url, 0, this.fileSize);
235242
await initWorkerPromise;
243+
this.isWorkerPaused = true;
244+
await this.requestWorker({ type: "PAUSE" }).catch(() => {
245+
this.isWorkerPaused = false;
246+
});
236247
} catch (e) {
237248
const err = toError(e);
238249
console.error("[Player] LoadSrc error:", err);

src/stores/status.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,9 @@ export const useStatusStore = defineStore("status", {
179179
playListShow: false,
180180
showFullPlayer: false,
181181
playerMetaShow: true,
182-
automixFxSeq: 0,
183-
automixEndedSeq: 0,
184182
currentTime: 0,
185183
duration: 0,
184+
progress: 0,
186185
currentTimeOffsetMap: {},
187186
songCoverTheme: {},
188187
pureLyricMode: false,

0 commit comments

Comments
 (0)