From 2fb86935ecb4fa40d129ec761e793e2a18364c8f Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 15 Feb 2022 19:43:06 -0800 Subject: [PATCH] Check player status before sending mpris interval --- src/components/player/Player.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/player/Player.tsx b/src/components/player/Player.tsx index 0b6e4cf..61ae0d2 100644 --- a/src/components/player/Player.tsx +++ b/src/components/player/Player.tsx @@ -321,14 +321,14 @@ const Player = ({ currentEntryList, muted, children }: any, ref: any) => { // for mpris-service's getPosition() function if (isLinux()) { const interval = setInterval(() => { - ipcRenderer.send( - 'current-position', - playQueue.currentPlayer === 1 - ? player1Ref.current.audioEl.current.currentTime - : player2Ref.current.audioEl.current.currentTime - ); - - if (player.status === 'PAUSED') { + if (player.status === 'PLAYING') { + ipcRenderer.send( + 'current-position', + playQueue.currentPlayer === 1 + ? player1Ref.current.audioEl.current.currentTime + : player2Ref.current.audioEl.current.currentTime + ); + } else { clearInterval(interval); } }, 500);