|
@@ -19,7 +19,7 @@ class LibraryScreen(BaseScreen):
|
|
|
self.current_directory = None
|
|
self.current_directory = None
|
|
|
self.library = None
|
|
self.library = None
|
|
|
self.library_strings = None
|
|
self.library_strings = None
|
|
|
- self.lookup_uri(None)
|
|
|
|
|
|
|
+ self.browse_uri(None)
|
|
|
|
|
|
|
|
def get_dirty_area(self):
|
|
def get_dirty_area(self):
|
|
|
return self.list_view.get_dirty_area()
|
|
return self.list_view.get_dirty_area()
|
|
@@ -27,12 +27,12 @@ class LibraryScreen(BaseScreen):
|
|
|
def go_inside_directory(self, uri):
|
|
def go_inside_directory(self, uri):
|
|
|
self.directory_list.append(self.current_directory)
|
|
self.directory_list.append(self.current_directory)
|
|
|
self.current_directory = uri
|
|
self.current_directory = uri
|
|
|
- self.lookup_uri(uri)
|
|
|
|
|
|
|
+ self.browse_uri(uri)
|
|
|
|
|
|
|
|
- def lookup_uri(self, uri):
|
|
|
|
|
|
|
+ def browse_uri(self, uri):
|
|
|
self.library_strings = []
|
|
self.library_strings = []
|
|
|
if uri is not None:
|
|
if uri is not None:
|
|
|
- self.library_strings.append("..")
|
|
|
|
|
|
|
+ self.library_strings.append("../")
|
|
|
self.library = self.manager.core.library.browse(uri).get()
|
|
self.library = self.manager.core.library.browse(uri).get()
|
|
|
for lib in self.library:
|
|
for lib in self.library:
|
|
|
self.library_strings.append(lib.name)
|
|
self.library_strings.append(lib.name)
|
|
@@ -42,7 +42,7 @@ class LibraryScreen(BaseScreen):
|
|
|
if len(self.directory_list):
|
|
if len(self.directory_list):
|
|
|
directory = self.directory_list.pop()
|
|
directory = self.directory_list.pop()
|
|
|
self.current_directory = directory
|
|
self.current_directory = directory
|
|
|
- self.lookup_uri(directory)
|
|
|
|
|
|
|
+ self.browse_uri(directory)
|
|
|
|
|
|
|
|
def update(self, screen, update_all):
|
|
def update(self, screen, update_all):
|
|
|
self.list_view.render(screen)
|
|
self.list_view.render(screen)
|
|
@@ -50,40 +50,28 @@ class LibraryScreen(BaseScreen):
|
|
|
def touch_event(self, touch_event):
|
|
def touch_event(self, touch_event):
|
|
|
clicked = self.list_view.touch_event(touch_event)
|
|
clicked = self.list_view.touch_event(touch_event)
|
|
|
if clicked is not None:
|
|
if clicked is not None:
|
|
|
- if touch_event.type == InputManager.long_click:
|
|
|
|
|
- if self.current_directory is not None:
|
|
|
|
|
- if clicked == 0:
|
|
|
|
|
- self.go_up_directory()
|
|
|
|
|
- else:
|
|
|
|
|
- self.play_uri(self.library[clicked - 1].uri,
|
|
|
|
|
- False)
|
|
|
|
|
- else:
|
|
|
|
|
- self.play_uri(self.library[clicked].uri, False)
|
|
|
|
|
- else:
|
|
|
|
|
- if self.current_directory is not None:
|
|
|
|
|
- if clicked == 0:
|
|
|
|
|
- self.go_up_directory()
|
|
|
|
|
- else:
|
|
|
|
|
- if self.library[
|
|
|
|
|
- clicked - 1].type == mopidy.models.Ref.TRACK:
|
|
|
|
|
- self.play_uri(
|
|
|
|
|
- self.library[clicked - 1].uri, True)
|
|
|
|
|
- else:
|
|
|
|
|
- self.go_inside_directory(
|
|
|
|
|
- self.library[clicked - 1].uri)
|
|
|
|
|
|
|
+ if self.current_directory is not None:
|
|
|
|
|
+ if clicked == 0:
|
|
|
|
|
+ self.go_up_directory()
|
|
|
else:
|
|
else:
|
|
|
if self.library[
|
|
if self.library[
|
|
|
- clicked].type == mopidy.models.Track:
|
|
|
|
|
- self.play_uri(self.library[clicked].uri, True)
|
|
|
|
|
|
|
+ clicked - 1].type == mopidy.models.Ref.TRACK:
|
|
|
|
|
+ self.play_uri(self.current_directory, clicked-1)
|
|
|
else:
|
|
else:
|
|
|
self.go_inside_directory(
|
|
self.go_inside_directory(
|
|
|
- self.library[clicked].uri)
|
|
|
|
|
|
|
+ self.library[clicked - 1].uri)
|
|
|
|
|
+ else:
|
|
|
|
|
+ self.go_inside_directory(
|
|
|
|
|
+ self.library[clicked].uri)
|
|
|
|
|
|
|
|
- def play_uri(self, uri, track):
|
|
|
|
|
|
|
+ def play_uri(self, uri, track_pos):
|
|
|
self.manager.core.tracklist.clear()
|
|
self.manager.core.tracklist.clear()
|
|
|
- if track:
|
|
|
|
|
- self.manager.core.tracklist.add(uri=uri)
|
|
|
|
|
- self.manager.core.playback.play()
|
|
|
|
|
- else:
|
|
|
|
|
- # TODO: add folder to tracks to play
|
|
|
|
|
- pass
|
|
|
|
|
|
|
+ tracks = []
|
|
|
|
|
+ for item in self.library:
|
|
|
|
|
+ if item.type == mopidy.models.Ref.TRACK:
|
|
|
|
|
+ tracks.append(self.manager.core.library.lookup(item.uri).get()[0])
|
|
|
|
|
+ else:
|
|
|
|
|
+ track_pos = track_pos - 1
|
|
|
|
|
+ self.manager.core.tracklist.add(tracks)
|
|
|
|
|
+ self.manager.core.playback.play(tl_track=self.manager.core.tracklist.tl_tracks.get()[track_pos])
|
|
|
|
|
+
|