Commit 913f8462 authored by fred's avatar fred

stamina: add "soft stop" in nonstop zones

parent 20fc4ca6
......@@ -120,6 +120,7 @@ class Command(BaseCommand):
if isinstance(slot, Nonstop):
self.playlist = self.get_playlist(slot, now, slot.end_datetime)
self.playhead = 0
self.softstop = False
while True:
now =
......@@ -130,8 +131,9 @@ class Command(BaseCommand):
print(now, track.title, track.duration,
'- future tracks:', [x.title for x in self.playlist[self.playhead + 1:self.playhead + 3]])
await self.player_process(track)
# TODO: detect "soft spot", to switch to another nonstop
# tranche
if self.softstop:
# track was left to finish, but now the playlist should stop.
self.playhead += 1
elif slot.is_stream():
print(now, 'playing stream',
......@@ -245,7 +247,10 @@ class Command(BaseCommand):
expected_slot = self.slot
if current_slot != expected_slot:
print(now, 'unexpected change', current_slot, 'vs', expected_slot)
if isinstance(current_slot, Nonstop) and not isinstance(expected_slot, Nonstop):
if isinstance(current_slot, Nonstop) and isinstance(expected_slot, Nonstop):
# ask for a softstop, i.e. finish the track then switch.
self.softstop = True
# interrupt nonstop
print('interrupting nonstop')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment