summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/rhlibrary/main.go8
-rw-r--r--src/rhlibrary/player.go28
3 files changed, 28 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index c784954..93c0e9d 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ EXECUTEABLE := rhlibrary
LIBS := "code.helsinki.at/rhrd-go/rddb" \
"github.com/gotk3/gotk3/glib" \
"github.com/gotk3/gotk3/gtk" \
- "github.com/revmischa/gst"
+ "github.com/spreadspace/go-gstreamer"
.PHONY: getlibs updatelibs vet format build clean distclean
diff --git a/src/rhlibrary/main.go b/src/rhlibrary/main.go
index a48fd14..5dea4ca 100644
--- a/src/rhlibrary/main.go
+++ b/src/rhlibrary/main.go
@@ -83,12 +83,16 @@ func main() {
}
defer db.Cleanup()
- player, _ := NewPlayer("/home/equinox/helsinki/rivenhell/contrib/rhlibrary/snd")
+ player, err := NewPlayer("/home/equinox/helsinki/rivenhell/contrib/rhlibrary/snd")
+ if err != nil {
+ rhl.Println("Error initializing Player:", err)
+ return
+ }
player.Play(1, 1)
mw, err := NewMainWindow(640, 360)
if err != nil {
- rhl.Println("Error initilizing Main Window:", err)
+ rhl.Println("Error initializing Main Window:", err)
return
}
diff --git a/src/rhlibrary/player.go b/src/rhlibrary/player.go
index 98b7e35..b6a6d93 100644
--- a/src/rhlibrary/player.go
+++ b/src/rhlibrary/player.go
@@ -26,10 +26,14 @@ package main
import (
"fmt"
- "github.com/revmischa/gst"
+ "github.com/spreadspace/go-gstreamer"
"path"
)
+func init() {
+ gst.Init(nil)
+}
+
type Player struct {
pipe *gst.Element
bus *gst.Bus
@@ -39,12 +43,18 @@ type Player struct {
func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) {
switch msg.GetType() {
case gst.MESSAGE_EOS:
- rhdl.Printf("EOS reached!")
+ rhdl.Printf("GStreamer Pipeline: EOS reached!")
p.pipe.SetState(gst.STATE_NULL)
+ case gst.MESSAGE_WARNING:
+ warn, _ := msg.ParseWarning()
+ rhdl.Printf("GStreamer Pipeline Warning: %s\n", warn)
case gst.MESSAGE_ERROR:
p.pipe.SetState(gst.STATE_NULL)
- _, errstr := msg.ParseError()
- rhdl.Printf("Error: %s\n", errstr)
+ err, _ := msg.ParseError()
+ rhdl.Printf("GStreamer Pipeline Error: %s\n", err)
+ case gst.MESSAGE_STATE_CHANGED:
+ default:
+ rhdl.Printf("GStreamer Message: unknown type '%s'", msg.GetTypeName())
}
}
@@ -61,11 +71,15 @@ func NewPlayer(basepath string) (p *Player, err error) {
p = &Player{}
p.basepath = path.Clean(basepath)
- p.pipe = gst.ElementFactoryMake("playbin", "autoplay")
- p.bus = p.pipe.GetBus()
+ if p.pipe, err = gst.ElementFactoryMake("playbin", "autoplay"); err != nil {
+ return
+ }
+ if p.bus, err = p.pipe.GetBus(); err != nil {
+ return
+ }
p.bus.AddSignalWatch()
- p.bus.Connect("message", (*Player).onMessage, p)
+ p.bus.Connect("message", func(bus *gst.Bus, msg *gst.Message) { p.onMessage(bus, msg) })
return
}