From 169f7a8b7d1d15306dfee3899fa242cfa77d9dba Mon Sep 17 00:00:00 2001 From: Sky-High Date: Thu, 30 Mar 2023 14:50:21 +0200 Subject: [PATCH 1/3] update previousTrack click event to avoid redundant calls to playbackManager --- src/components/nowPlayingBar/nowPlayingBar.js | 22 +++++++++++-------- src/components/remotecontrol/remotecontrol.js | 22 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/components/nowPlayingBar/nowPlayingBar.js b/src/components/nowPlayingBar/nowPlayingBar.js index 2bf29a2a9c..6c72473ec7 100644 --- a/src/components/nowPlayingBar/nowPlayingBar.js +++ b/src/components/nowPlayingBar/nowPlayingBar.js @@ -169,18 +169,22 @@ import { appRouter } from '../appRouter'; elem.querySelector('.previousTrackButton').addEventListener('click', function (e) { if (currentPlayer) { - if (lastPlayerState.NowPlayingItem.MediaType === 'Audio' && (currentPlayer._currentTime >= 5 || !playbackManager.previousTrack(currentPlayer))) { - // Cancel this event if doubleclick is fired - if (e.detail > 1 && playbackManager.previousTrack(currentPlayer)) { + if (lastPlayerState.NowPlayingItem.MediaType === 'Audio') { + // Cancel this event if doubleclick is fired. The actual previousTrack will be processed by the 'dblclick' event + if (e.detail > 1 ) { + return; + } + // Return to start of track, unless we are already (almost) at the beginning. In the latter case, continue and move + // to the previous track, unless we are at the first track so no previous track exists. + if (currentPlayer._currentTime >= 2 || lastPlayerState.NowPlayingItem.IndexNumber == 1 ) { + playbackManager.seekPercent(0, currentPlayer); + // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. + // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. + positionSlider.value = 0; return; } - playbackManager.seekPercent(0, currentPlayer); - // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. - // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. - positionSlider.value = 0; - } else { - playbackManager.previousTrack(currentPlayer); } + playbackManager.previousTrack(currentPlayer); } }); diff --git a/src/components/remotecontrol/remotecontrol.js b/src/components/remotecontrol/remotecontrol.js index 26b7220bce..66e0d533f6 100644 --- a/src/components/remotecontrol/remotecontrol.js +++ b/src/components/remotecontrol/remotecontrol.js @@ -763,18 +763,22 @@ export default function () { context.querySelector('.btnPreviousTrack').addEventListener('click', function (e) { if (currentPlayer) { - if (lastPlayerState.NowPlayingItem.MediaType === 'Audio' && (currentPlayer._currentTime >= 5 || !playbackManager.previousTrack(currentPlayer))) { - // Cancel this event if doubleclick is fired - if (e.detail > 1 && playbackManager.previousTrack(currentPlayer)) { + if (lastPlayerState.NowPlayingItem.MediaType === 'Audio') { + // Cancel this event if doubleclick is fired. The actual previousTrack will be processed by the 'dblclick' event + if (e.detail > 1 ) { + return; + } + // Return to start of track, unless we are already (almost) at the beginning. In the latter case, continue and move + // to the previous track, unless we are at the first track so no previous track exists. + if (currentPlayer._currentTime >= 2 || lastPlayerState.NowPlayingItem.IndexNumber == 1 ) { + playbackManager.seekPercent(0, currentPlayer); + // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. + // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. + positionSlider.value = 0; return; } - playbackManager.seekPercent(0, currentPlayer); - // This is done automatically by playbackManager. However, setting this here gives instant visual feedback. - // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. - positionSlider.value = 0; - } else { - playbackManager.previousTrack(currentPlayer); } + playbackManager.previousTrack(currentPlayer); } }); From a4ea68f40b82fec090ff73cc850d4ea44feeff5f Mon Sep 17 00:00:00 2001 From: Sky-High Date: Thu, 13 Apr 2023 08:05:09 +0200 Subject: [PATCH 2/3] add support for playlists in general iso albums only --- src/components/nowPlayingBar/nowPlayingBar.js | 2 +- src/components/remotecontrol/remotecontrol.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/nowPlayingBar/nowPlayingBar.js b/src/components/nowPlayingBar/nowPlayingBar.js index 6c72473ec7..dcb30d323e 100644 --- a/src/components/nowPlayingBar/nowPlayingBar.js +++ b/src/components/nowPlayingBar/nowPlayingBar.js @@ -176,7 +176,7 @@ import { appRouter } from '../appRouter'; } // Return to start of track, unless we are already (almost) at the beginning. In the latter case, continue and move // to the previous track, unless we are at the first track so no previous track exists. - if (currentPlayer._currentTime >= 2 || lastPlayerState.NowPlayingItem.IndexNumber == 1 ) { + if (currentPlayer._currentTime >= 2 || playbackManager.getCurrentPlaylistIndex(currentPlayer) <= 1) { playbackManager.seekPercent(0, currentPlayer); // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. diff --git a/src/components/remotecontrol/remotecontrol.js b/src/components/remotecontrol/remotecontrol.js index 66e0d533f6..7a67d9ffb3 100644 --- a/src/components/remotecontrol/remotecontrol.js +++ b/src/components/remotecontrol/remotecontrol.js @@ -770,7 +770,7 @@ export default function () { } // Return to start of track, unless we are already (almost) at the beginning. In the latter case, continue and move // to the previous track, unless we are at the first track so no previous track exists. - if (currentPlayer._currentTime >= 2 || lastPlayerState.NowPlayingItem.IndexNumber == 1 ) { + if (currentPlayer._currentTime >= 2 || playbackManager.getCurrentPlaylistIndex(currentPlayer) <= 1) { playbackManager.seekPercent(0, currentPlayer); // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. From 7a0535d9c7c5a5984e59c5178707cbe1dab52a40 Mon Sep 17 00:00:00 2001 From: Sky-High Date: Tue, 18 Apr 2023 21:01:58 +0200 Subject: [PATCH 3/3] reset long doubleclick time to 5 seconds --- src/components/nowPlayingBar/nowPlayingBar.js | 2 +- src/components/remotecontrol/remotecontrol.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/nowPlayingBar/nowPlayingBar.js b/src/components/nowPlayingBar/nowPlayingBar.js index dcb30d323e..5fee5f2db1 100644 --- a/src/components/nowPlayingBar/nowPlayingBar.js +++ b/src/components/nowPlayingBar/nowPlayingBar.js @@ -176,7 +176,7 @@ import { appRouter } from '../appRouter'; } // Return to start of track, unless we are already (almost) at the beginning. In the latter case, continue and move // to the previous track, unless we are at the first track so no previous track exists. - if (currentPlayer._currentTime >= 2 || playbackManager.getCurrentPlaylistIndex(currentPlayer) <= 1) { + if (currentPlayer._currentTime >= 5 || playbackManager.getCurrentPlaylistIndex(currentPlayer) <= 1) { playbackManager.seekPercent(0, currentPlayer); // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround. diff --git a/src/components/remotecontrol/remotecontrol.js b/src/components/remotecontrol/remotecontrol.js index 4ae8bebc24..8fc8d4667a 100644 --- a/src/components/remotecontrol/remotecontrol.js +++ b/src/components/remotecontrol/remotecontrol.js @@ -771,7 +771,7 @@ export default function () { } // Return to start of track, unless we are already (almost) at the beginning. In the latter case, continue and move // to the previous track, unless we are at the first track so no previous track exists. - if (currentPlayer._currentTime >= 2 || playbackManager.getCurrentPlaylistIndex(currentPlayer) <= 1) { + if (currentPlayer._currentTime >= 5 || playbackManager.getCurrentPlaylistIndex(currentPlayer) <= 1) { playbackManager.seekPercent(0, currentPlayer); // This is done automatically by playbackManager, however, setting this here gives instant visual feedback. // TODO: Check why seekPercentage doesn't reflect the changes inmmediately, so we can remove this workaround.