addet sorting and chagned some logging
This commit is contained in:
parent
27a221318e
commit
e57373cfa2
1 changed files with 17 additions and 1 deletions
18
tui/tui.go
18
tui/tui.go
|
@ -137,8 +137,24 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
case "enter":
|
||||
if i := m.results.Index(); i != -1 {
|
||||
selectedVideo := m.videos[i]
|
||||
log.Printf("Playing video: %s", selectedVideo.URL)
|
||||
cmd := player.PlayVideo(selectedVideo.URL)
|
||||
return m, tea.ExecProcess(cmd, nil)
|
||||
|
||||
// Execute the command and handle any errors
|
||||
if err := cmd.Start(); err != nil {
|
||||
m.err = fmt.Errorf("this video URL cannot be played: %w", err)
|
||||
log.Printf("Error starting video playback: %v", err)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Optionally, wait for the command to finish
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
log.Printf("Error during video playback: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
case "s":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue