diff --git a/tui/tui.go b/tui/tui.go index d4e3d93..b23bc5e 100644 --- a/tui/tui.go +++ b/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":