Add controlls for looping the playlist
This commit is contained in:
parent
f273c23e37
commit
7f1469fbb0
|
@ -104,6 +104,15 @@ def playlist_move(index1:int, index2:int):
|
||||||
args = urlencode(locals())
|
args = urlencode(locals())
|
||||||
return f"playlist/move?{args}", None
|
return f"playlist/move?{args}", None
|
||||||
|
|
||||||
|
@request_get
|
||||||
|
def get_playlist_looping():
|
||||||
|
return f"playlist/loop"
|
||||||
|
|
||||||
|
@request_post
|
||||||
|
def playlist_set_looping(looping:bool):
|
||||||
|
return f"playlist/loop?loop={str(bool(looping)).lower()}", None
|
||||||
|
|
||||||
|
|
||||||
@request_get
|
@request_get
|
||||||
def get_playback_pos():
|
def get_playback_pos():
|
||||||
return f"time"
|
return f"time"
|
||||||
|
|
|
@ -50,6 +50,9 @@ class RemiApp(App):
|
||||||
self.playlist.table = gui.Table()
|
self.playlist.table = gui.Table()
|
||||||
self.playlist.table.append_from_list([['#', 'Name', "length", "", "", ""]], fill_title=True)
|
self.playlist.table.append_from_list([['#', 'Name', "length", "", "", ""]], fill_title=True)
|
||||||
|
|
||||||
|
self.playlist.looping = gui.CheckBoxLabel("<i><small>loop playlist</small></i>")
|
||||||
|
self.playlist.looping.set_on_click_listener(self.on_playlist_set_looping)
|
||||||
|
|
||||||
self.playlist.shuffle = gui.Button("SHUFFLE")
|
self.playlist.shuffle = gui.Button("SHUFFLE")
|
||||||
self.playlist.shuffle.set_on_click_listener(self.on_playlist_clear_shuffle)
|
self.playlist.shuffle.set_on_click_listener(self.on_playlist_clear_shuffle)
|
||||||
|
|
||||||
|
@ -167,13 +170,20 @@ class RemiApp(App):
|
||||||
|
|
||||||
right_container.append(self.playlist.table)
|
right_container.append(self.playlist.table)
|
||||||
|
|
||||||
|
playlist_controls = gui.HBox()
|
||||||
|
playlist_controls.style["width"] = "100%"
|
||||||
|
playlist_controls.style["justify-content"] = "space-between"
|
||||||
|
playlist_controls.style["margin-right"] = "0.25em"
|
||||||
|
playlist_controls.style["margin-bottom"] = "0.8em"
|
||||||
|
|
||||||
|
playlist_controls.append(self.playlist.looping)
|
||||||
|
|
||||||
playlist_button_container = gui.HBox()
|
playlist_button_container = gui.HBox()
|
||||||
playlist_button_container.append(self.playlist.shuffle)
|
playlist_button_container.append(self.playlist.shuffle)
|
||||||
playlist_button_container.append(self.playlist.clear)
|
playlist_button_container.append(self.playlist.clear)
|
||||||
playlist_button_container.style["margin-left"] = "auto"
|
playlist_controls.append(playlist_button_container)
|
||||||
playlist_button_container.style["margin-right"] = "0.25em"
|
|
||||||
playlist_button_container.style["margin-bottom"] = "0.8em"
|
right_container.append(playlist_controls)
|
||||||
right_container.append(playlist_button_container)
|
|
||||||
|
|
||||||
return root_container
|
return root_container
|
||||||
|
|
||||||
|
@ -238,6 +248,11 @@ class RemiApp(App):
|
||||||
def on_table_item_remove_click(self, row_widget, playlist_item):
|
def on_table_item_remove_click(self, row_widget, playlist_item):
|
||||||
api.playlist_remove(playlist_item["index"])
|
api.playlist_remove(playlist_item["index"])
|
||||||
@call_as_thread
|
@call_as_thread
|
||||||
|
def on_playlist_set_looping(self, row_widget):
|
||||||
|
toggled = not row_widget.get_value()
|
||||||
|
api.playlist_set_looping(toggled)
|
||||||
|
row_widget.set_value(toggled)
|
||||||
|
@call_as_thread
|
||||||
def on_playlist_clear_shuffle(self, row_widget):
|
def on_playlist_clear_shuffle(self, row_widget):
|
||||||
api.playlist_shuffle()
|
api.playlist_shuffle()
|
||||||
@call_as_thread
|
@call_as_thread
|
||||||
|
@ -250,6 +265,8 @@ class RemiApp(App):
|
||||||
is_playing = api.is_playing()
|
is_playing = api.is_playing()
|
||||||
self.set_playing(is_playing)
|
self.set_playing(is_playing)
|
||||||
|
|
||||||
|
self.playlist.looping.set_value(api.get_playlist_looping())
|
||||||
|
|
||||||
if is_playing: # update seekbar and timestamp
|
if is_playing: # update seekbar and timestamp
|
||||||
try:
|
try:
|
||||||
playback_pos = api.get_playback_pos()
|
playback_pos = api.get_playback_pos()
|
||||||
|
|
Loading…
Reference in New Issue