fixing up the queue / skip / rewind a bit

This commit is contained in:
JISAUAY committed 2025-09-08 14:30:02 -05:00
1 parent 9ac286bda4
commit 9836c24a25
1 file changed
+19 -2
+19 -2
View File
@@ -248,7 +248,8 @@ class PlaylistSongs(Screen):
app.update_queue_table()
def action_queue(self) -> None:
app.queue_song(self._find_selected_song())
song_id: int = self._find_selected_song()
app.queue_song(self.songs[song_id])
# Returns index of selected song
def _find_selected_song(self) -> int:
@@ -388,6 +389,14 @@ class QueueTable(Widget):
if self.selected_row_key >= len(queue):
return # Avoid index out of bounds
# Add currently playing song to history
if app.currently_playing:
app.play_history.append(app.currently_playing)
# Add all songs before the selected one to history
songs_to_skip = queue[:self.selected_row_key]
app.play_history.extend(songs_to_skip)
song_to_play = queue[self.selected_row_key]
# The new queue is everything after the selected song
@@ -585,10 +594,18 @@ class TextualSubpyPlayer(App):
self.play_song(queue.pop(0))
def action_rewind(self) -> None:
if not self.play_history:
return
if self.check_playing_timer:
self.check_playing_timer.stop()
self.play_song(self.play_history.pop())
if self.currently_playing:
self.song_queue.insert(0, self.currently_playing)
song_to_play = self.play_history.pop()
self.play_song(song_to_play)
self.update_queue_table()
def update_progress(self) -> None:
if isinstance(self.screen, MainView) and self.currently_playing: