Skip to content

Commit

Permalink
Implemented sound.length for gstreamer backend (see http://stacko…
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fraser committed Apr 26, 2012
1 parent e2e4e17 commit 0baae8e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kivy/core/audio/audio_gstreamer.py
Expand Up @@ -104,4 +104,17 @@ def _set_volume(self, volume):
self._data.set_property('volume', volume)
return super(SoundGstreamer, self)._set_volume(volume)

def _get_length(self):
if self._data is not None:
if self._data.get_state()[1] != gst.STATE_PLAYING:
self._data.set_state(gst.STATE_PLAYING)
try:
self._data.get_state()
return self._data.query_duration(gst.Format(gst.FORMAT_TIME))[0] / 1000000000.
finally:
self._data.set_state(gst.STATE_NULL)
else:
return self._data.query_duration(gst.Format(gst.FORMAT_TIME))[0] / 1000000000.
return super(SoundGstreamer, self)._get_length()

SoundLoader.register(SoundGstreamer)

0 comments on commit 0baae8e

Please sign in to comment.