Skip to content

Commit

Permalink
Fix repeat and onpause logic
Browse files Browse the repository at this point in the history
Signed-off-by: arctic4161 <arctic4161@gmail.com>
  • Loading branch information
Arctic4161 committed Aug 27, 2024
1 parent 61b5ddd commit 8f304b0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
37 changes: 23 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ def __init__(self, **kwargs):
GUILayout.gui_resume_check = Clock.schedule_interval(self.set_gui_from_check, 1)
GUILayout.get_update_slider = Clock.schedule_interval(self.wait_update_slider, 1)

@staticmethod
def set_gui_resume(arg0, arg1, arg2, arg3):
MDApp.get_running_app().root.ids.play_btt.opacity = arg0
MDApp.get_running_app().root.ids.play_btt.disabled = arg1
MDApp.get_running_app().root.ids.pause_btt.disabled = arg2
MDApp.get_running_app().root.ids.pause_btt.opacity = arg3
MDApp.get_running_app().root.ids.next_btt.disabled = arg2
MDApp.get_running_app().root.ids.previous_btt.disabled = arg2

def second_screen(self):
songs = self.get_play_list()
self.ids.rv.data = [{'text': str(x[:-4])} for x in songs]
Expand Down Expand Up @@ -521,13 +512,29 @@ def check_are_we_playing(self, *val):
GUILayout.check_are_play = ''.join(val)

def set_gui_from_check(self, dt):
if GUILayout.check_are_play == 'False':
GUILayout.set_gui_resume(0, True, False, 1)
if GUILayout.check_are_play == 'True':
MDApp.get_running_app().root.ids.play_btt.opacity = 1
MDApp.get_running_app().root.ids.play_btt.disabled = False
MDApp.get_running_app().root.ids.pause_btt.disabled = True
MDApp.get_running_app().root.ids.pause_btt.opacity = 0
GUILayout.gui_resume_check.cancel()
elif GUILayout.check_are_play == 'False':
MDApp.get_running_app().root.ids.play_btt.opacity = 0
MDApp.get_running_app().root.ids.play_btt.disabled = True
MDApp.get_running_app().root.ids.pause_btt.disabled = False
MDApp.get_running_app().root.ids.pause_btt.opacity = 1
GUILayout.gui_resume_check.cancel()
elif GUILayout == 'True':
GUILayout.set_gui_resume(1, False, True, 0)
elif GUILayout.check_are_play == 'None':
MDApp.get_running_app().root.ids.play_btt.opacity = 0
MDApp.get_running_app().root.ids.play_btt.disabled = True
MDApp.get_running_app().root.ids.pause_btt.disabled = True
MDApp.get_running_app().root.ids.pause_btt.opacity = 0
MDApp.get_running_app().root.ids.previous_btt.opacity = 0
MDApp.get_running_app().root.ids.next_btt.opacity = 0
MDApp.get_running_app().root.ids.next_btt.disabled = True
MDApp.get_running_app().root.ids.previous_btt.disabled = True
GUILayout.gui_resume_check.cancel()
elif GUILayout.set_gui_resume is None:
else:
pass

def stop(self):
Expand Down Expand Up @@ -622,9 +629,11 @@ def stop_service(self):

def on_pause(self):
GUILayout.send('iampaused', ':(')
GUILayout.get_update_slider.cancel()
return True

def on_resume(self):
GUILayout.get_update_slider()
GUILayout.gui_resume_check()
GUILayout.send('iamawake', 'Heelloo')

Expand Down
8 changes: 6 additions & 2 deletions service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def warning(self, msg):


class Gui_sounds():
sounds = None
length = None
previous_songs = []
set_local = None
Expand Down Expand Up @@ -122,7 +123,7 @@ def check_for_next():
while True:
if (Gui_sounds.sound is not None and (Gui_sounds.paused is False or Gui_sounds.sound.state == 'play')
and Gui_sounds.length - Gui_sounds.sound.get_pos() <= 1):
if Gui_sounds.previous is True:
if Gui_sounds.previous is True or Gui_sounds.sound.loop is True:
continue
if Gui_sounds.playlist is False or Gui_sounds.playlist == 'False':
Gui_sounds.send("reset_gui", "reset_gui")
Expand Down Expand Up @@ -250,7 +251,10 @@ def refresh_gui(self, *val):
Gui_sounds.main_paused = False
if Gui_sounds.load_from_service:
Gui_sounds.send("update_image", [Gui_sounds.set_local])
Gui_sounds.send("are_we", Gui_sounds.paused)
if Gui_sounds.sound is None:
Gui_sounds.send("are_we", "None")
else:
Gui_sounds.send("are_we", Gui_sounds.paused)

def loop(self, *val):
Gui_sounds.looping_bool = ''.join(val)
Expand Down

0 comments on commit 8f304b0

Please sign in to comment.