mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-26 13:49:21 +08:00
implement sound play
This commit is contained in:
parent
56318c2ec7
commit
8c41ff87e2
@ -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':
|
||||
|
||||
|
2
queue.go
2
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)
|
||||
|
12
start.go
12
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user