Hello,
Sorry for the long delay but had some challenges in my professional live.
Looking in to the code of PlaybackController.seek(time_position ) I found:
if self.get_state() == PlaybackState.STOPPED:
self.play()
So I thought it should be enough to use seek, but also with the fix that doesnt work.
I tested the fix with sleep and that works with the disadvantage that sometimes the first few milliseconds of the track are played before it seeks too the new position:
def cb_card_inserted(self):
self.seek_time = 160000
logger.info("Card inserted")
track_uris = ['file:///home/pi/Music/Blues/004%20doggin%27%20the%20blues.mp3', 'file:///home/pi/Music/Blues/003%20friendless%20blues.mp3']
self.core.tracklist.add(uris=track_uris)
play = self.core.playback.play().get()
sleep(1)
seek = self.core.playback.seek(160000).get()
sleep(1)
logger.info("Playback State: {0}".format(self.core.playback.get_state().get()))
logger.info("Seek command result: {0}".format(seek))
Using track_playback_started
would initiate a seek
with every new track. I therfore used that instead:
def playback_state_changed(self, old_state, new_state):
logger.info("Playback State changed from: {0} to: {1}".format(old_state, new_state))
if old_state == "stopped":
seek = self.core.playback.seek(self.seek_time).get()
logger.info("Seek command result: {0}".format(seek))
self.seek_time = 0
If there is no other solution available from developement of mopidy I will see what way I will go in my project.
BTW. In the seek function you use two times:
if time_position < 0:
time_position = 0
Not that this cause issues or would be important but you can save two lines of code and make the code clearer/cleaner .
Thank you very much for the fix and I will look forward to test it in the new release of mopidy.
cheers
Michael