change hard-coded timeout to config timeout

This commit is contained in:
raziman 2020-07-03 11:32:19 +08:00
parent 4d4a120f15
commit e2593cb541
3 changed files with 10 additions and 11 deletions

View File

@ -11,7 +11,6 @@ import (
"github.com/faiface/beep/effects"
"github.com/faiface/beep/mp3"
"github.com/faiface/beep/speaker"
"github.com/spf13/viper"
)
type Song struct {
@ -81,9 +80,8 @@ func (p *Player) Run() {
popupMessage := fmt.Sprintf("%s\n\n[ %s ]", song.name, fmtDuration(p.length))
timeout := viper.GetInt("popup_timeout")
timedPopup(" Current Song ", popupMessage, time.Second*time.Duration(timeout))
timedPopup(" Current Song ", popupMessage, popupTimeout)
done := make(chan bool, 1)

View File

@ -118,11 +118,11 @@ func InitPlaylist() *Playlist {
if err != nil {
timedPopup(
" Error ",
"Unable to delete dir "+selectedDir.Name, time.Second*5)
"Unable to delete dir "+selectedDir.Name, popupTimeout)
} else {
timedPopup(
" Success ",
selectedDir.Name+"\nhas been deleted successfully", time.Second*5)
selectedDir.Name+"\nhas been deleted successfully", popupTimeout)
playlist.Refresh()
}
@ -152,11 +152,11 @@ func InitPlaylist() *Playlist {
if err != nil {
timedPopup(
" Error ", "Unable to delete "+audioFile.Name, time.Second*5)
" Error ", "Unable to delete "+audioFile.Name, popupTimeout)
} else {
timedPopup(
" Success ",
audioFile.Name+"\nhas been deleted successfully", time.Second*5)
audioFile.Name+"\nhas been deleted successfully", popupTimeout)
playlist.Refresh()
}
@ -476,7 +476,7 @@ func Ytdl(url string, selPlaylist *tview.TreeNode) {
selAudioFile := selPlaylist.GetReference().(*AudioFile)
selPlaylistName := selAudioFile.Name
timedPopup(" Ytdl ", "Downloading", time.Second*5)
timedPopup(" Ytdl ", "Downloading", popupTimeout)
// specify the output path for ytdl
outputDir := fmt.Sprintf(
@ -502,7 +502,7 @@ func Ytdl(url string, selPlaylist *tview.TreeNode) {
err := cmd.Run()
if err != nil {
timedPopup(" Error ", "Error running youtube-dl", time.Second*5)
timedPopup(" Error ", "Error running youtube-dl", popupTimeout)
return
}
@ -523,7 +523,7 @@ func Ytdl(url string, selPlaylist *tview.TreeNode) {
timedPopup(
" Ytdl ",
downloadFinishedMessage,
time.Second*5,
popupTimeout,
)
app.Draw()

View File

@ -93,7 +93,7 @@ func volumePopup(volume float64) {
"50",
)
timedPopup(" Volume ", progress, time.Second*5)
timedPopup(" Volume ", progress, popupTimeout)
}
@ -114,6 +114,7 @@ func helpPopup() {
"- volume down",
"? toggle help",
"Y download audio",
"a add playlist",
}
list := tview.NewList().ShowSecondaryText(false)