Switch to local media once download completes

This commit is contained in:
Sumner Evans
2019-08-08 17:42:11 -06:00
parent 594ecaed81
commit 653268ebf5
2 changed files with 10 additions and 1 deletions

View File

@@ -419,13 +419,21 @@ class LibremsonicApp(Gtk.Application):
self.player.reset()
self.state.song_progress = 0
def on_song_download_complete(_):
# This will now return the local media.
downloaded_filename = CacheManager.get_song_filename_or_stream(
song)[0]
self.player.play_media(downloaded_filename,
self.state.song_progress, song)
GLib.idle_add(self.update_window)
# If streaming, also download the song.
# TODO: make it configurable if we do this download
if stream:
CacheManager.batch_download_songs(
[song.id],
before_download=lambda: self.update_window(),
on_song_download_complete=lambda _: self.update_window(),
on_song_download_complete=on_song_download_complete,
)
self.player.play_media(uri, self.state.song_progress, song)

View File

@@ -485,6 +485,7 @@ class AlbumWithSongs(Gtk.Box):
margin_top=15,
margin_left=10,
margin_right=10,
margin_bottom=10,
)
self.album_songs.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)