summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--player/player.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/player/player.go b/player/player.go
index 95bab81..90c607c 100644
--- a/player/player.go
+++ b/player/player.go
@@ -29,6 +29,7 @@ import (
"github.com/spreadspace/go-gstreamer"
"io/ioutil"
"log"
+ "os"
"path"
)
@@ -109,6 +110,23 @@ func (p *Player) onMessage(msg *gst.Message) {
func (p *Player) load(cart, cut uint) (resp loadResult) {
filename := path.Join(p.basepath, fmt.Sprintf("%06d_%03d.wav", cart, cut))
+
+ var file *os.File
+ if file, resp.err = os.Open(filename); resp.err != nil {
+ resp.err = fmt.Errorf("player: %s", resp.err)
+ return
+ }
+ if info, err := file.Stat(); err != nil {
+ resp.err = fmt.Errorf("player: %s", err)
+ return
+ } else {
+ if info.IsDir() {
+ resp.err = fmt.Errorf("player error: '%s' is a directory", filename)
+ return
+ }
+ }
+ file.Close()
+
p.pipe.SetProperty("uri", "file://"+filename)
p.pipe.SetState(gst.STATE_PAUSED)
return