summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-13 15:10:34 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-13 15:10:34 (GMT)
commit180d099cebff3d9e11cb33d3f10f1dcc1ca95fa6 (patch)
treee22f2f22d35a5cb0cd7d10b61d6b6e88699e76d7 /src
parente70b210ca5ed370214c44c97643eb6d6107c84b6 (diff)
moved to different gstreamer bindings
Diffstat (limited to 'src')
-rw-r--r--src/rhlibrary/main.go8
-rw-r--r--src/rhlibrary/player.go28
2 files changed, 27 insertions, 9 deletions
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
}