diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-01-13 16:23:11 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-01-13 16:23:11 (GMT) |
commit | 72c7c990622c347c5462fa37bc0da989e220eb97 (patch) | |
tree | acc05f605e47f41b69879d055010d55581f82bb3 /src/rhlibrary | |
parent | 180d099cebff3d9e11cb33d3f10f1dcc1ca95fa6 (diff) |
player: fetch duration from pipeline
Diffstat (limited to 'src/rhlibrary')
-rw-r--r-- | src/rhlibrary/player.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rhlibrary/player.go b/src/rhlibrary/player.go index b6a6d93..983198f 100644 --- a/src/rhlibrary/player.go +++ b/src/rhlibrary/player.go @@ -47,11 +47,18 @@ func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) { p.pipe.SetState(gst.STATE_NULL) case gst.MESSAGE_WARNING: warn, _ := msg.ParseWarning() - rhdl.Printf("GStreamer Pipeline Warning: %s\n", warn) + rhdl.Printf("GStreamer Pipeline Warning: %s", warn) case gst.MESSAGE_ERROR: p.pipe.SetState(gst.STATE_NULL) err, _ := msg.ParseError() - rhdl.Printf("GStreamer Pipeline Error: %s\n", err) + rhdl.Printf("GStreamer Pipeline Error: %s", err) + case gst.MESSAGE_ASYNC_DONE: + len, ok := p.pipe.QueryDuration(gst.FORMAT_TIME) + if ok { + rhdl.Printf("GStreamer Pipeline: loaded file has length: %d.%d s", len/1000000000, len%1000000000) + } else { + rhdl.Printf("GStreamer Pipeline Error: unable to query duration of file") + } case gst.MESSAGE_STATE_CHANGED: default: rhdl.Printf("GStreamer Message: unknown type '%s'", msg.GetTypeName()) |