Automatically go to next song
This commit is contained in:
@@ -42,18 +42,8 @@ class LibremsonicApp(Gtk.Application):
|
|||||||
value,
|
value,
|
||||||
self.state.current_song.duration,
|
self.state.current_song.duration,
|
||||||
)
|
)
|
||||||
|
if abs((value or 0) - self.state.current_song.duration) < 0.1:
|
||||||
@self.player.property_observer('eof-reached')
|
GLib.idle_add(self.on_next_track, None, None)
|
||||||
def file_end(_, value):
|
|
||||||
print('eof', value)
|
|
||||||
return
|
|
||||||
if value is None:
|
|
||||||
# TODO handle repeat
|
|
||||||
current_idx = self.state.play_queue.index(
|
|
||||||
self.state.current_song)
|
|
||||||
has_next_song = current_idx < len(self.state.play_queue) - 1
|
|
||||||
if has_next_song:
|
|
||||||
self.on_next_track(None, None)
|
|
||||||
|
|
||||||
# Handle command line option parsing.
|
# Handle command line option parsing.
|
||||||
def do_command_line(self, command_line):
|
def do_command_line(self, command_line):
|
||||||
@@ -210,12 +200,13 @@ class LibremsonicApp(Gtk.Application):
|
|||||||
lambda *a, **k: CacheManager.get_song_details(*a, **k),
|
lambda *a, **k: CacheManager.get_song_details(*a, **k),
|
||||||
)
|
)
|
||||||
def play_song(self, song: Child):
|
def play_song(self, song: Child):
|
||||||
self.state.playing = True
|
self.update_window()
|
||||||
|
|
||||||
song_filename_future = CacheManager.get_song_filename(song)
|
song_filename_future = CacheManager.get_song_filename(song)
|
||||||
|
|
||||||
def filename_future_done(song_file):
|
def filename_future_done(song_file):
|
||||||
self.state.current_song = song
|
self.state.current_song = song
|
||||||
|
self.state.playing = True
|
||||||
self.update_window()
|
self.update_window()
|
||||||
self.player.loadfile(song_file, 'replace')
|
self.player.loadfile(song_file, 'replace')
|
||||||
self.player.pause = False
|
self.player.pause = False
|
||||||
|
@@ -42,7 +42,7 @@ class PlayerControls(Gtk.ActionBar):
|
|||||||
|
|
||||||
has_current_song = hasattr(state, 'current_song')
|
has_current_song = hasattr(state, 'current_song')
|
||||||
has_prev_song, has_next_song = False, False
|
has_prev_song, has_next_song = False, False
|
||||||
if has_current_song:
|
if has_current_song and state.current_song.id in state.play_queue:
|
||||||
# TODO will need to change when repeat is implemented
|
# TODO will need to change when repeat is implemented
|
||||||
current = state.play_queue.index(state.current_song.id)
|
current = state.play_queue.index(state.current_song.id)
|
||||||
has_prev_song = current > 0
|
has_prev_song = current > 0
|
||||||
|
@@ -69,7 +69,6 @@ class PlaylistsPanel(Gtk.Paned):
|
|||||||
# The playlist view on the right side
|
# The playlist view on the right side
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
loading_overlay = Gtk.Overlay(name='playlist-view-overlay')
|
loading_overlay = Gtk.Overlay(name='playlist-view-overlay')
|
||||||
playlist_view_scroll_window = Gtk.ScrolledWindow()
|
|
||||||
playlist_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
playlist_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
|
||||||
# Playlist info panel
|
# Playlist info panel
|
||||||
@@ -111,6 +110,7 @@ class PlaylistsPanel(Gtk.Paned):
|
|||||||
playlist_box.pack_start(self.big_info_panel, False, True, 0)
|
playlist_box.pack_start(self.big_info_panel, False, True, 0)
|
||||||
|
|
||||||
# Playlist songs list
|
# Playlist songs list
|
||||||
|
playlist_view_scroll_window = Gtk.ScrolledWindow()
|
||||||
|
|
||||||
def create_column(header, text_idx, bold=False, align=0, width=None):
|
def create_column(header, text_idx, bold=False, align=0, width=None):
|
||||||
renderer = Gtk.CellRendererText(
|
renderer = Gtk.CellRendererText(
|
||||||
@@ -152,10 +152,10 @@ class PlaylistsPanel(Gtk.Paned):
|
|||||||
create_column('DURATION', 4, align=1, width=40))
|
create_column('DURATION', 4, align=1, width=40))
|
||||||
|
|
||||||
self.playlist_songs.connect('row-activated', self.on_song_double_click)
|
self.playlist_songs.connect('row-activated', self.on_song_double_click)
|
||||||
playlist_box.pack_end(self.playlist_songs, True, True, 0)
|
playlist_view_scroll_window.add(self.playlist_songs)
|
||||||
|
|
||||||
playlist_view_scroll_window.add(playlist_box)
|
playlist_box.pack_end(playlist_view_scroll_window, True, True, 0)
|
||||||
loading_overlay.add(playlist_view_scroll_window)
|
loading_overlay.add(playlist_box)
|
||||||
|
|
||||||
playlist_view_spinner = Gtk.Spinner(active=True)
|
playlist_view_spinner = Gtk.Spinner(active=True)
|
||||||
playlist_view_spinner.start()
|
playlist_view_spinner.start()
|
||||||
@@ -195,9 +195,13 @@ class PlaylistsPanel(Gtk.Paned):
|
|||||||
return Gtk.Label(text, name=name, halign=Gtk.Align.START, **params)
|
return Gtk.Label(text, name=name, halign=Gtk.Align.START, **params)
|
||||||
|
|
||||||
def update(self, state: ApplicationState):
|
def update(self, state: ApplicationState):
|
||||||
self.update_playlist_list()
|
|
||||||
self.set_playlist_view_loading(False)
|
self.set_playlist_view_loading(False)
|
||||||
self.set_playlist_art_loading(False)
|
self.set_playlist_art_loading(False)
|
||||||
|
self.update_playlist_list()
|
||||||
|
selected = self.playlist_list.get_selected_row()
|
||||||
|
if selected:
|
||||||
|
playlist_id = self.playlist_ids[selected.get_index() - 1]
|
||||||
|
self.update_playlist_view(playlist_id)
|
||||||
|
|
||||||
def set_playlist_list_loading(self, loading_status):
|
def set_playlist_list_loading(self, loading_status):
|
||||||
if loading_status:
|
if loading_status:
|
||||||
|
Reference in New Issue
Block a user