Added a "Playlist" class.

This commit is contained in:
The Wobbler 2024-12-24 17:22:30 +01:00
parent 1190059218
commit 94269fdae4
7 changed files with 119 additions and 53 deletions

View file

@ -13,7 +13,7 @@ class Settings:
self.settings.visibilityChanged.connect(self.update_all)
self.settings.save_button.pressed.connect(self.write_settings)
def update_all(self, settings_visible: bool=True):
def update_all(self, _=True): # ignore visible parameter passed by visibilityChanged event
self.settings.file_settings.library_path_input.setText(self.app.settings.library_path)
def update_settings(self, key, value):

View file

@ -37,24 +37,24 @@ class TrackControl:
self.track_control.track_progress_slider.sliderReleased.connect(self.on_slider_release)
def previous_track(self):
if len(self.app.player.current_playlist) > 0:
if self.app.player.current_playlist.has_tracks():
self.app.player.previous_track()
def stop(self):
if len(self.app.player.current_playlist) > 0:
if self.app.player.current_playlist.has_tracks():
self.app.player.stop()
def next_track(self):
if len(self.app.player.current_playlist) > 0:
if self.app.player.current_playlist.has_tracks():
self.app.player.next_track()
def on_slider_release(self):
if len(self.app.player.current_playlist) > 0:
if self.app.player.current_playlist.has_tracks():
self.app.player.seek(self.track_control.track_progress_slider.value())
def on_track_start(self):
if self.app.player.playing:
duration = self.app.player.current_track.duration
duration = self.app.player.current_playlist.current_track.duration
self.track_control.track_progress_slider.setRange(
0,
@ -73,7 +73,7 @@ class TrackControl:
if remaining == -1:
remaining = self.app.player.track_progress.remaining_time
track_duration = self.app.player.current_track.duration
track_duration = self.app.player.current_playlist.current_track.duration
progress = track_duration - remaining
@ -95,7 +95,7 @@ class TrackControl:
self.app.player.pause()
self.track_control.toggle_play_button.setIcon(self.play_icon)
elif len(self.app.player.current_playlist) > 0: # stopped but tracks in the current playlist
elif self.app.player.current_playlist.has_tracks(): # stopped but tracks in the current playlist
self.app.player.start_playing()
self.track_control.toggle_play_button.setIcon(self.pause_icon)