forked from Wobbl/Wobuzz
Added loading of playlists to the process-dock.
This commit is contained in:
parent
6786a3dcd8
commit
301896e12c
4 changed files with 48 additions and 19 deletions
|
@ -161,11 +161,14 @@ class Player:
|
|||
track = self.current_playlist.tracks[self.current_playlist.current_track_index + 1]
|
||||
|
||||
if not track.cached:
|
||||
self.app.gui.on_background_job_start("track_caching")
|
||||
self.app.gui.on_background_job_start(
|
||||
"Loading Track",
|
||||
"Loading next track in the background so it starts immediately."
|
||||
)
|
||||
|
||||
track.cache()
|
||||
|
||||
self.app.gui.on_background_job_stop("track_caching")
|
||||
self.app.gui.on_background_job_stop("Loading Track")
|
||||
|
||||
def cache_next_track(self):
|
||||
# function that creates a thread which will cache the next track
|
||||
|
|
|
@ -40,9 +40,20 @@ class Playlist:
|
|||
self.current_track = None
|
||||
|
||||
def load_from_paths(self, paths):
|
||||
num_tracks = len(paths)
|
||||
|
||||
i = 0
|
||||
|
||||
while i < len(paths):
|
||||
process_title = f'Loading Playlist "{self.title}"'
|
||||
|
||||
self.app.gui.on_background_job_start(
|
||||
process_title,
|
||||
f'Loading the tracks of "{self.title}".',
|
||||
num_tracks,
|
||||
lambda: i
|
||||
)
|
||||
|
||||
while i < num_tracks:
|
||||
path = paths[i]
|
||||
|
||||
if os.path.isfile(path):
|
||||
|
@ -52,6 +63,8 @@ class Playlist:
|
|||
|
||||
self.loaded = True
|
||||
|
||||
self.app.gui.on_background_job_stop(process_title)
|
||||
|
||||
def load(self):
|
||||
loading_thread = threading.Thread(target=self.loading_thread)
|
||||
loading_thread.start()
|
||||
|
@ -79,9 +92,19 @@ class Playlist:
|
|||
lines = m3u.split("\n") # m3u entries are separated by newlines
|
||||
lines = lines[:-1] # remove last entry because it is just an empty string
|
||||
|
||||
i = 0
|
||||
num_lines = len(lines)
|
||||
|
||||
i = 0
|
||||
|
||||
process_title = f'Loading Playlist "{self.title}"'
|
||||
|
||||
self.app.gui.on_background_job_start(
|
||||
process_title,
|
||||
f'Loading the tracks of "{self.title}".',
|
||||
num_lines,
|
||||
lambda: i
|
||||
)
|
||||
|
||||
while i < num_lines:
|
||||
line = lines[i]
|
||||
|
||||
|
@ -100,6 +123,8 @@ class Playlist:
|
|||
|
||||
self.loaded = True
|
||||
|
||||
self.app.gui.on_background_job_stop(process_title)
|
||||
|
||||
def load_from_wbz(self, path):
|
||||
self.load_from_m3u(path) # placeholder
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue