simple seeking implementation

This commit is contained in:
aditya-K2 2022-09-09 01:31:51 +05:30
parent b2c5575c8b
commit ea3fc105a4
4 changed files with 17 additions and 0 deletions

View File

@ -24,6 +24,7 @@ var (
"PORT": "6600",
"DEFAULT_IMAGE_PATH": "default.jpg",
"CACHE_DIR": utils.CheckDirectoryFmt(USER_CACHE_DIR),
"SEEK_OFFSET": 10,
}
)

View File

@ -50,6 +50,8 @@ var (
100: "deleteSongFromPlaylist",
63: "FocusSearch",
47: "FocusBuffSearch",
98: "SeekBackward",
101: "SeekForward",
}
)

11
main.go
View File

@ -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

View File

@ -121,5 +121,8 @@ func progressFunction() (string, string, string, float64) {
text = " ---:---"
percentage = 0
}
if percentage > 100 {
percentage = 0
}
return song, top, text, percentage
}