forked from Wobbl/Wobuzz
Got it working, but it's not better than before...
This commit is contained in:
parent
6134c21ce4
commit
22ffd211df
7 changed files with 48 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import threading
|
||||
from PyQt6.QtCore import Qt
|
||||
from .track import Track
|
||||
|
||||
|
@ -18,7 +19,8 @@ class Playlist:
|
|||
self.tracks: list[Track] = []
|
||||
self.current_track_index = 0
|
||||
self.current_track: Track | None = None
|
||||
self.view = None
|
||||
self.views = {} # dict of id(LibraryDock): PlaylistView
|
||||
self.loaded = False
|
||||
|
||||
self.path = os.path.expanduser(
|
||||
f"{app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
|
@ -41,9 +43,13 @@ class Playlist:
|
|||
|
||||
i += 1
|
||||
|
||||
# set current track to the first track if there is no currently playing track
|
||||
if self.current_track is None and self.has_tracks():
|
||||
self.current_track = self.tracks[0]
|
||||
self.save()
|
||||
|
||||
self.tracks = []
|
||||
|
||||
def load(self):
|
||||
loading_thread = threading.Thread(target=self.load_from_m3u, args=(self.path,))
|
||||
loading_thread.start()
|
||||
|
||||
def load_from_m3u(self, path):
|
||||
file = open(path, "r")
|
||||
|
@ -64,14 +70,18 @@ class Playlist:
|
|||
|
||||
continue
|
||||
|
||||
self.tracks.append(Track(self.app, line, cache=i==0)) # first track is cached
|
||||
self.append_track(Track(self.app, line, cache=i==0)) # first track is cached
|
||||
|
||||
i += 1
|
||||
|
||||
print("kolupp")
|
||||
|
||||
# set current track to the first track if there is no currently playing track
|
||||
if self.current_track is None and self.has_tracks():
|
||||
self.current_track = self.tracks[0]
|
||||
|
||||
self.loaded = True
|
||||
|
||||
def load_from_wbz(self, path):
|
||||
pass
|
||||
|
||||
|
@ -149,10 +159,14 @@ class Playlist:
|
|||
self.app.library.playlists.remove(self)
|
||||
|
||||
def append_track(self, track):
|
||||
for dock_id in self.views:
|
||||
view = self.views[dock_id]
|
||||
view.append_track(track)
|
||||
|
||||
self.tracks.append(track)
|
||||
|
||||
if self.view:
|
||||
self.view.append_track(track)
|
||||
print(track.tags.title)
|
||||
|
||||
|
||||
def h_last_track(self):
|
||||
# get last track in history (only gets used in player.history)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue