diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-01-28 23:23:00 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-01-28 23:23:11 (GMT) |
commit | e08d24fd199bee764e5dfcf751c21a9d7774387f (patch) | |
tree | 44280bc73fd741015269f3ba1d652ab42cf03f82 | |
parent | 9458e4371d6d3deccd6c9f2e9e29fc21509913ce (diff) |
improved handling of seek position
-rw-r--r-- | player/player.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/player/player.go b/player/player.go index 0717983..5d4e1d4 100644 --- a/player/player.go +++ b/player/player.go @@ -153,14 +153,21 @@ func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) { p.updateChan <- updateData{duration: p.duration} err, _ := msg.ParseError() p.stdlog.Printf("GStreamer Pipeline Error: %s", err) + case gst.MESSAGE_DURATION_CHANGED: + fallthrough case gst.MESSAGE_ASYNC_DONE: duration, ok := p.pipe.QueryDuration(gst.FORMAT_TIME) if ok { p.duration = time.Duration(duration) - p.updateChan <- updateData{duration: p.duration} + pos, ok := p.pipe.QueryPosition(gst.FORMAT_TIME) + if !ok { + p.stdlog.Printf("GStreamer Pipeline Error: unable to query playback position") + } + p.updateChan <- updateData{duration: p.duration, pos: time.Duration(pos)} } else { p.stdlog.Printf("GStreamer Pipeline Error: unable to query duration of file") } + case gst.MESSAGE_ELEMENT: s := msg.GetStructure() peak := s.Data["peak"].(gst.GValueArray) @@ -173,6 +180,11 @@ func (p *Player) onMessage(bus *gst.Bus, msg *gst.Message) { pos := time.Duration(s.Data["stream-time"].(uint64)) p.updateChan <- updateData{duration: p.duration, pos: pos, meter: meter} case gst.MESSAGE_STATE_CHANGED: + case gst.MESSAGE_STREAM_STATUS: + case gst.MESSAGE_STREAM_START: + case gst.MESSAGE_TAG: + case gst.MESSAGE_NEW_CLOCK: + case gst.MESSAGE_RESET_TIME: default: p.dbglog.Printf("GStreamer Message: unknown type '%s'", msg.GetTypeName()) } |