40 lines
714 B
Go
40 lines
714 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path"
|
|
)
|
|
|
|
func (s *State) NowPlaying() string {
|
|
if s.CurrentFile == "" {
|
|
return "Nothing 😴"
|
|
} else {
|
|
return s.CurrentFile
|
|
}
|
|
}
|
|
|
|
var ErrChooseFile = errors.New("please choose a file")
|
|
|
|
// TODO: make it possible to specific timestamp
|
|
func (s *State) PlayVideo(filename string, seconds int) (err error) {
|
|
if filename == "" {
|
|
err = ErrChooseFile
|
|
return
|
|
}
|
|
|
|
err = s.playFile(filename)
|
|
|
|
return
|
|
}
|
|
|
|
// returns if media can be watched
|
|
func (s *State) IsLivestreamReady() (bool, error) {
|
|
if _, err := os.Stat(path.Join(s.StreamCacheDir, OUTFILE)); os.IsNotExist(err) {
|
|
return false, nil
|
|
} else if err != nil {
|
|
return false, err
|
|
} else {
|
|
return true, nil
|
|
}
|
|
}
|