OOPed the way playlist views are created.
This commit is contained in:
parent
88b846f3b6
commit
028c38b1b6
7 changed files with 61 additions and 67 deletions
|
@ -13,6 +13,7 @@ class Playlist:
|
|||
self.tracks: list[Track] = []
|
||||
self.current_track_index = 0
|
||||
self.current_track: Track | None = None
|
||||
self.view = None
|
||||
|
||||
def load_from_paths(self, paths):
|
||||
i = 0
|
||||
|
@ -21,7 +22,7 @@ class Playlist:
|
|||
path = paths[i]
|
||||
|
||||
if os.path.isfile(path):
|
||||
self.tracks.append(Track(self.app, path, cache=i==0)) # first track is cached
|
||||
self.tracks.append(Track(self.app, i, path, cache=i==0)) # first track is cached
|
||||
|
||||
i += 1
|
||||
|
||||
|
@ -47,7 +48,7 @@ class Playlist:
|
|||
|
||||
continue
|
||||
|
||||
self.tracks.append(Track(self.app, line, cache=i==0)) # first track is cached
|
||||
self.tracks.append(Track(self.app, i, line, cache=i==0)) # first track is cached
|
||||
|
||||
i += 1
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@ class Track:
|
|||
Class containing data for a track like file path, raw data...
|
||||
"""
|
||||
|
||||
def __init__(self, app, path: str, property_string: str=None, cache: bool=False):
|
||||
def __init__(self, app, index: int, 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
|
||||
|
||||
|
@ -30,6 +31,8 @@ class Track:
|
|||
self.sound = None
|
||||
self.duration = 0
|
||||
|
||||
self.item = None
|
||||
|
||||
if cache:
|
||||
self.cache()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue