From e45d18d9ce5c2bfa1887d15fdae9bc089f562cc7 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Sat, 25 Jan 2025 23:52:30 +0100 Subject: [PATCH] feat: Seeking keyboard shorcuts (closes #406) --- CHANGELOG.md | 1 + src/Core/UI/Adjunct.elm | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b24e61b9..fdffd5c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fixed issue with missing extensions when downloading playlists. - Removed Fission/Webnative user layer (discontinued). - Minor improvements/fixes to the artwork downloading process. +- Added keyboard shortcuts to seek back and forward. - No longer cache all background images when first loading the app. - A lot of javascript code refactoring. diff --git a/src/Core/UI/Adjunct.elm b/src/Core/UI/Adjunct.elm index 46e2ffdb..9d8832c9 100644 --- a/src/Core/UI/Adjunct.elm +++ b/src/Core/UI/Adjunct.elm @@ -76,13 +76,40 @@ keyboardInput msg model = [ Keyboard.Character "]", Keyboard.Control ] -> Queue.shift m - -- TODO: - -- [ Keyboard.Character "{", Keyboard.Shift, Keyboard.Control ] -> - -- Audio.seek ((m.audioPosition - 10) / m.audioDuration) m - -- - -- [ Keyboard.Character "}", Keyboard.Shift, Keyboard.Control ] -> - -- Audio.seek ((m.audioPosition + 10) / m.audioDuration) m - -- + [ Keyboard.Character "{", Keyboard.Shift, Keyboard.Control ] -> + case m.nowPlaying of + Just { duration, item, playbackPosition } -> + case duration of + Just d -> + Audio.seek + { trackId = (Tuple.second item.identifiedTrack).id + , progress = (playbackPosition - 10) / d + } + m + + Nothing -> + Return.singleton m + + Nothing -> + Return.singleton m + + [ Keyboard.Character "}", Keyboard.Shift, Keyboard.Control ] -> + case m.nowPlaying of + Just { duration, item, playbackPosition } -> + case duration of + Just d -> + Audio.seek + { trackId = (Tuple.second item.identifiedTrack).id + , progress = (playbackPosition + 10) / d + } + m + + Nothing -> + Return.singleton m + + Nothing -> + Return.singleton m + -- Meta key -- [ Keyboard.Character "K", Keyboard.Meta ] -> -- knotmirror 0.0.1