Fix old use of state constants
This commit is contained in:
parent
0eaee6b70d
commit
3d7fc78010
@ -92,6 +92,7 @@ class BasePlaybackController(object):
|
|||||||
|
|
||||||
def __init__(self, backend):
|
def __init__(self, backend):
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
|
self._state = self.STOPPED
|
||||||
self.consume = False
|
self.consume = False
|
||||||
self.current_track = None
|
self.current_track = None
|
||||||
self.random = False
|
self.random = False
|
||||||
@ -117,21 +118,22 @@ class BasePlaybackController(object):
|
|||||||
def state(self, new_state):
|
def state(self, new_state):
|
||||||
(old_state, self._state) = (self.state, new_state)
|
(old_state, self._state) = (self.state, new_state)
|
||||||
logger.debug(u'Changing state: %s -> %s', old_state, new_state)
|
logger.debug(u'Changing state: %s -> %s', old_state, new_state)
|
||||||
if old_state in (self.PLAY, self.STOP) and new_state == self.PLAY:
|
if (old_state in (self.PLAYING, self.STOPPED)
|
||||||
|
and new_state == self.PLAYING):
|
||||||
self._play_time_start()
|
self._play_time_start()
|
||||||
elif old_state == self.PLAY and new_state == self.PAUSE:
|
elif old_state == self.PLAYING and new_state == self.PAUSED:
|
||||||
self._play_time_pause()
|
self._play_time_pause()
|
||||||
elif old_state == self.PAUSE and new_state == self.PLAY:
|
elif old_state == self.PAUSED and new_state == self.PLAYING:
|
||||||
self._play_time_resume()
|
self._play_time_resume()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def time_position(self):
|
def time_position(self):
|
||||||
if self.state == self.PLAY:
|
if self.state == self.PLAYING:
|
||||||
time_since_started = int(time.time()) - self._play_time_started
|
time_since_started = int(time.time()) - self._play_time_started
|
||||||
return self._play_time_accumulated + time_since_started
|
return self._play_time_accumulated + time_since_started
|
||||||
elif self.state == self.PAUSE:
|
elif self.state == self.PAUSED:
|
||||||
return self._play_time_accumulated
|
return self._play_time_accumulated
|
||||||
elif self.state == self.STOP:
|
elif self.state == self.STOPPED:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def _play_time_start(self):
|
def _play_time_start(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user