Implemented editing of playlist.

(Changes aren't persistent.)
This commit is contained in:
The Wobbler 2025-01-25 18:04:46 +01:00
parent f0969d013d
commit cba4fd67fa
5 changed files with 37 additions and 12 deletions

View file

@ -34,8 +34,7 @@ class Player:
self.app.gui.track_control.on_playstate_update()
# cache next track so it immediately starts when the current track finishes
caching_thread = threading.Thread(target=self.cache_next_track)
caching_thread.start()
self.cache_next_track()
def track_finished(self):
if not self.current_playlist.on_last_track():
@ -127,7 +126,7 @@ class Player:
self.play()
self.track_progress.start()
def cache_next_track(self):
def caching_thread_function(self):
# cache the next track
# (usually run in separate thread)
if self.current_playlist.on_last_track():
@ -138,3 +137,7 @@ class Player:
if not track.cached:
track.cache()
def cache_next_track(self):
# function that creates a thread which will cache the next track
caching_thread = threading.Thread(target=self.caching_thread_function)
caching_thread.start()

View file

@ -22,7 +22,7 @@ class Playlist:
path = paths[i]
if os.path.isfile(path):
self.tracks.append(Track(self.app, i, path, cache=i==0)) # first track is cached
self.tracks.append(Track(self.app, path, cache=i==0)) # first track is cached
i += 1
@ -48,7 +48,7 @@ class Playlist:
continue
self.tracks.append(Track(self.app, i, line, cache=i==0)) # first track is cached
self.tracks.append(Track(self.app, line, cache=i==0)) # first track is cached
i += 1

View file

@ -18,9 +18,8 @@ class Track:
Class containing data for a track like file path, raw data...
"""
def __init__(self, app, index: int, path: str, property_string: str=None, cache: bool=False):
def __init__(self, app, path: str, property_string: str=None, cache: bool=False):
self.app = app
self.index_custom_sort = index
self.path = path
self.property_string = property_string