Fix seek return value tests

This commit is contained in:
Thomas Adamcik 2010-08-20 00:17:34 +02:00
parent ef03bbe19e
commit dbdfb3a8c7
3 changed files with 13 additions and 7 deletions

View File

@ -440,7 +440,10 @@ class BasePlaybackController(object):
:param time_position: time position in milliseconds
:type time_position: int
:rtype: :class:`True` if successful, else :class:`False`
"""
# FIXME I think return value is only realy usefull for internal
# testing, as such it should probably not be exposed in api.
if self.state == self.STOPPED:
self.play()
elif self.state == self.PAUSED:
@ -455,7 +458,7 @@ class BasePlaybackController(object):
self._play_time_started = self._current_wall_time
self._play_time_accumulated = time_position
self._seek(time_position)
return self._seek(time_position)
def _seek(self, time_position):
"""

View File

@ -62,9 +62,8 @@ class LocalPlaybackController(BasePlaybackController):
return self._set_state('PLAYING')
def _seek(self, time_position):
self._send({'command': 'set_position', 'position': time_position})
if self.state == self.STOPPED:
self._set_state('PLAYING')
return self._send_recv({'command': 'set_position',
'position': time_position})
@property
def time_position(self):

View File

@ -109,7 +109,9 @@ class GStreamerProcess(BaseProcess):
elif message['command'] == 'set_volume':
self.set_volume(message['volume'])
elif message['command'] == 'set_position':
self.set_position(message['position'])
response = self.set_position(message['position'])
connection = unpickle_connection(message['reply_to'])
connection.send(response)
elif message['command'] == 'get_position':
response = self.get_position()
connection = unpickle_connection(message['reply_to'])
@ -191,9 +193,11 @@ class GStreamerProcess(BaseProcess):
gst_volume.set_property('volume', volume / 100.0)
def set_position(self, position):
self.gst_pipeline.seek_simple(gst.Format(gst.FORMAT_TIME),
self.gst_pipeline.get_state() # block until state changes are done
handeled= self.gst_pipeline.seek_simple(gst.Format(gst.FORMAT_TIME),
gst.SEEK_FLAG_FLUSH, position * gst.MSECOND)
self.gst_pipeline.get_state()
self.gst_pipeline.get_state() # block until seek is done
return handeled
def get_position(self):
try: