From 72971873f68ccb22756da6eee31da5c6dacbe719 Mon Sep 17 00:00:00 2001 From: raziman Date: Sat, 13 Feb 2021 21:48:46 +0800 Subject: [PATCH 1/2] fix #17 --- player.go | 9 +++++++++ queue.go | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/player.go b/player.go index f1cdb50..f938183 100644 --- a/player.go +++ b/player.go @@ -308,3 +308,12 @@ func (p *Player) seek(pos int) error { p.i = pos - 1 return err } + +// isPaused is used to distinguish the player between pause and stop +func (p *Player) isPaused() bool { + if p.ctrl == nil { + return false + } + + return p.ctrl.Paused +} diff --git a/queue.go b/queue.go index 09b8955..7b2d3f3 100644 --- a/queue.go +++ b/queue.go @@ -154,8 +154,9 @@ func (q *Queue) dequeue() (*AudioFile, error) { // Add item to the list and returns the length of the queue func (q *Queue) enqueue(audioFile *AudioFile) (int, error) { - //this is to fix the problem bulk_add when paused - if !gomu.player.isRunning && os.Getenv("TEST") == "false" { + player := gomu.player + + if !player.isRunning && !player.isPaused() && os.Getenv("TEST") == "false" { gomu.player.isRunning = true From 4f201217bd5126a0d61000132ce44c7ecfa5dfca Mon Sep 17 00:00:00 2001 From: raziman Date: Sat, 13 Feb 2021 21:49:37 +0800 Subject: [PATCH 2/2] run go fmt --- command.go | 1 - playlist.go | 4 +--- queue.go | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/command.go b/command.go index 1b490bf..bba9741 100644 --- a/command.go +++ b/command.go @@ -10,7 +10,6 @@ import ( "github.com/ztrue/tracerr" ) - type Command struct { commands map[string]func() } diff --git a/playlist.go b/playlist.go index b841814..42a77e0 100644 --- a/playlist.go +++ b/playlist.go @@ -356,7 +356,7 @@ func (p *Playlist) addSongToPlaylist( displayText := songName if viper.GetBool("general.emoji") { - displayText = fmt.Sprintf(" %s %s", + displayText = fmt.Sprintf(" %s %s", viper.GetString("emoji.file"), songName) } @@ -459,7 +459,6 @@ func (p *Playlist) findAudioFile(audioName string) (*AudioFile, error) { return selNode, nil } - func (p *Playlist) rename(newName string) error { currentNode := p.GetCurrentNode() @@ -524,7 +523,6 @@ Download: } - // Download audio from youtube audio and adds the song to the selected playlist func ytdl(url string, selPlaylist *tview.TreeNode) error { diff --git a/queue.go b/queue.go index 7b2d3f3..ce53ba7 100644 --- a/queue.go +++ b/queue.go @@ -321,7 +321,6 @@ func (q *Queue) getSavedQueue() ([]string, error) { return records, nil } - func (q *Queue) help() []string { return []string{