From 9c406f449c43170493ceae5370294ba0ec57ca04 Mon Sep 17 00:00:00 2001 From: Leonardo Fernandes Contrera Date: Wed, 8 Apr 2026 23:13:02 -0300 Subject: [PATCH] fix: fixing restarting music when pausing it --- source/services/player/player.service.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/services/player/player.service.ts b/source/services/player/player.service.ts index 2a2deff..c8a351b 100644 --- a/source/services/player/player.service.ts +++ b/source/services/player/player.service.ts @@ -359,11 +359,10 @@ class PlayerService { return; } - this.currentTrackId = videoId || null; - // Stop any existing playback this.stop(); + this.currentTrackId = videoId || null; this.currentUrl = url; if (options?.volume !== undefined) { this.currentVolume = options.volume; @@ -530,17 +529,20 @@ class PlayerService { resume(): void { logger.debug('PlayerService', 'resume() called'); - this.isPlaying = true; - if (this.ipcSocket && !this.ipcSocket.destroyed) { + if (!!this.ipcSocket && !this.ipcSocket.destroyed) { this.sendIpcCommand(['set_property', 'pause', false]); - // Reapply volume after resume to ensure audio isn't muted + this.isPlaying = true; if (this.currentVolume !== undefined) { setTimeout(() => { this.sendIpcCommand(['set_property', 'volume', this.currentVolume]); }, 100); } - } else if (!this.isPlaying && !this.mpvProcess && this.currentUrl) { + return; + } + + if (!this.mpvProcess && this.currentUrl) { void this.play(this.currentUrl, {volume: this.currentVolume}); + return; } }