mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-28 13:48:53 +08:00
implement sound play
This commit is contained in:
parent
56318c2ec7
commit
8c41ff87e2
@ -15,7 +15,7 @@ type AudioFile struct {
|
|||||||
Parent *tview.TreeNode
|
Parent *tview.TreeNode
|
||||||
}
|
}
|
||||||
|
|
||||||
func playlist(list *tview.List) *tview.TreeView {
|
func Playlist(list *tview.List, player *Player) *tview.TreeView {
|
||||||
|
|
||||||
musicDir := "./music"
|
musicDir := "./music"
|
||||||
|
|
||||||
@ -69,10 +69,14 @@ func playlist(list *tview.List) *tview.TreeView {
|
|||||||
case 'l':
|
case 'l':
|
||||||
|
|
||||||
if audioFile.IsAudioFile {
|
if audioFile.IsAudioFile {
|
||||||
|
|
||||||
list.AddItem(audioFile.Name, audioFile.Path, 0, nil)
|
list.AddItem(audioFile.Name, audioFile.Path, 0, nil)
|
||||||
|
player.Push(audioFile.Path)
|
||||||
|
|
||||||
|
if !player.IsRunning {
|
||||||
|
go player.Run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currNode.SetExpanded(true)
|
currNode.SetExpanded(true)
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
||||||
|
2
queue.go
2
queue.go
@ -37,6 +37,8 @@ func Queue(playlist *tview.Box) *tview.List {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list.SetHighlightFullLine(true)
|
list.SetHighlightFullLine(true)
|
||||||
list.SetBorder(true).SetTitle("Queue")
|
list.SetBorder(true).SetTitle("Queue")
|
||||||
list.SetSelectedBackgroundColor(tcell.ColorDarkCyan)
|
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.PrimitiveBackgroundColor = tcell.ColorDefault
|
||||||
tview.Styles.BorderColor = tcell.ColorAntiqueWhite
|
tview.Styles.BorderColor = tcell.ColorAntiqueWhite
|
||||||
|
|
||||||
|
player := &Player{}
|
||||||
|
|
||||||
child3 := NowPlayingBar()
|
child3 := NowPlayingBar()
|
||||||
child2 := Queue(child3)
|
child2 := Queue(child3)
|
||||||
child1 := playlist(child2)
|
child1 := Playlist(child2, player)
|
||||||
|
|
||||||
flex := Layout(app, child1, child2, child3)
|
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
|
return event
|
||||||
|
Loading…
x
Reference in New Issue
Block a user