From ea3fc105a4262ce51f8802561c4a04cd26c6ddd9 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Fri, 9 Sep 2022 01:31:51 +0530 Subject: [PATCH] simple seeking implementation --- config/config.go | 1 + config/kMap.go | 2 ++ main.go | 11 +++++++++++ ui/progressBar.go | 3 +++ 4 files changed, 17 insertions(+) diff --git a/config/config.go b/config/config.go index dda1381..ad32698 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ var ( "PORT": "6600", "DEFAULT_IMAGE_PATH": "default.jpg", "CACHE_DIR": utils.CheckDirectoryFmt(USER_CACHE_DIR), + "SEEK_OFFSET": 10, } ) diff --git a/config/kMap.go b/config/kMap.go index ad949e4..d75e4b9 100644 --- a/config/kMap.go +++ b/config/kMap.go @@ -50,6 +50,8 @@ var ( 100: "deleteSongFromPlaylist", 63: "FocusSearch", 47: "FocusBuffSearch", + 98: "SeekBackward", + 101: "SeekForward", } ) diff --git a/main.go b/main.go index de183d5..b881bec 100644 --- a/main.go +++ b/main.go @@ -65,6 +65,7 @@ func main() { var Volume int64 var Random, Repeat bool + var SeekOffset = viper.GetInt("SEEK_OFFSET") if _v, err := CONN.Status(); err != nil { utils.Print("RED", "Could Not Get the MPD Status\n") @@ -218,6 +219,16 @@ func main() { "FocusBuffSearch": func() { views.GetCurrentView().FocusBuffSearchView() }, + "SeekForward": func() { + if err := CONN.SeekCur(time.Second*time.Duration(SeekOffset), true); err != nil { + notify.Notify.Send("Could Not Seek Forward in the Song") + } + }, + "SeekBackward": func() { + if err := CONN.SeekCur(-1*time.Second*time.Duration(SeekOffset), true); err != nil { + notify.Notify.Send("Could Not Seek Backward in the Song") + } + }, } // Generating the Key Map Based on the Function Map Here Basically the Values will be flipped diff --git a/ui/progressBar.go b/ui/progressBar.go index 0143c7a..f950bb7 100644 --- a/ui/progressBar.go +++ b/ui/progressBar.go @@ -121,5 +121,8 @@ func progressFunction() (string, string, string, float64) { text = " ---:---" percentage = 0 } + if percentage > 100 { + percentage = 0 + } return song, top, text, percentage }