fixed the queue getting doubled on skip / play next
This commit is contained in:
1 parent
9836c24a25
commit
b6b07e830b
1 file changed
+18
-11
+18
-11
@@ -519,10 +519,6 @@ class TextualSubpyPlayer(App):
|
||||
self.title = "SubPy"
|
||||
self.switch_mode('main')
|
||||
|
||||
def on_key(self, event: events.Key) -> None:
|
||||
# logging.debug(f'Key Pressed {event.name}')
|
||||
pass
|
||||
|
||||
@work(exclusive=True)
|
||||
async def play_song(self, song: SubSonic.Song) -> None:
|
||||
self.currently_playing = song
|
||||
@@ -569,15 +565,19 @@ class TextualSubpyPlayer(App):
|
||||
file.write(content)
|
||||
|
||||
def check_done_playing(self) -> None:
|
||||
if not pygame.mixer.music.get_busy() and not self.is_paused:
|
||||
if not pygame.mixer.music.get_busy() and not self.is_paused and self.currently_playing:
|
||||
self.play_history.append(self.currently_playing)
|
||||
queue = self.user_queue
|
||||
queue.extend(self.song_queue)
|
||||
|
||||
next_song = queue.pop(0)
|
||||
next_song: SubSonic.Song | None = None
|
||||
if self.user_queue:
|
||||
next_song = self.user_queue.pop(0)
|
||||
elif self.song_queue:
|
||||
next_song = self.song_queue.pop(0)
|
||||
|
||||
if next_song:
|
||||
self.play_song(next_song)
|
||||
|
||||
if self.check_playing_timer:
|
||||
self.check_playing_timer.stop()
|
||||
|
||||
def action_skip(self) -> None:
|
||||
@@ -588,10 +588,14 @@ class TextualSubpyPlayer(App):
|
||||
if self.currently_playing:
|
||||
self.play_history.append(self.currently_playing)
|
||||
|
||||
queue = self.user_queue
|
||||
queue.extend(self.song_queue)
|
||||
next_song: SubSonic.Song | None = None
|
||||
if self.user_queue:
|
||||
next_song = self.user_queue.pop(0)
|
||||
elif self.song_queue:
|
||||
next_song = self.song_queue.pop(0)
|
||||
|
||||
self.play_song(queue.pop(0))
|
||||
if next_song:
|
||||
self.play_song(next_song)
|
||||
|
||||
def action_rewind(self) -> None:
|
||||
if not self.play_history:
|
||||
@@ -655,6 +659,9 @@ class TextualSubpyPlayer(App):
|
||||
self.song_queue.append(song)
|
||||
self.update_queue_table()
|
||||
|
||||
def on_key(self, event: events.Key) -> None:
|
||||
logging.debug(event.key)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = TextualSubpyPlayer()
|
||||
app.run()
|
||||
Reference in new issue
Block a user