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