diff --git a/playlist.go b/playlist.go index 9f1a4a5..38acf54 100644 --- a/playlist.go +++ b/playlist.go @@ -15,7 +15,7 @@ type AudioFile struct { Parent *tview.TreeNode } -func playlist(list *tview.List) *tview.TreeView { +func Playlist(list *tview.List, player *Player) *tview.TreeView { musicDir := "./music" @@ -69,10 +69,14 @@ func playlist(list *tview.List) *tview.TreeView { case 'l': if audioFile.IsAudioFile { - list.AddItem(audioFile.Name, audioFile.Path, 0, nil) + player.Push(audioFile.Path) + if !player.IsRunning { + go player.Run() + } } + currNode.SetExpanded(true) case 'h': diff --git a/queue.go b/queue.go index c5bb4f8..bd4a121 100644 --- a/queue.go +++ b/queue.go @@ -37,6 +37,8 @@ func Queue(playlist *tview.Box) *tview.List { return nil }) + + list.SetHighlightFullLine(true) list.SetBorder(true).SetTitle("Queue") list.SetSelectedBackgroundColor(tcell.ColorDarkCyan) diff --git a/start.go b/start.go index bf19355..2922f50 100644 --- a/start.go +++ b/start.go @@ -17,9 +17,11 @@ func start(app *tview.Application) { tview.Styles.PrimitiveBackgroundColor = tcell.ColorDefault tview.Styles.BorderColor = tcell.ColorAntiqueWhite + player := &Player{} + child3 := NowPlayingBar() child2 := Queue(child3) - child1 := playlist(child2) + child1 := Playlist(child2, player) flex := Layout(app, child1, child2, child3) @@ -49,6 +51,14 @@ func start(app *tview.Application) { }) + case ' ': + + if player.ctrl.Paused { + player.Play() + } else { + player.Pause() + } + } return event