seperated controls from artist song frame
this fixes the controls moving if song name long modified updater to restart completely if killed/encounters exception
This commit is contained in:
@@ -18,23 +18,29 @@ import numpy
|
||||
|
||||
# import speech_recognition as sr
|
||||
if os.name == 'posix':
|
||||
client_id = "df61ecadf09941eb87e693d37f3ad178"
|
||||
client_secret = "ba97992d614e48d6b0d023998b2957cb"
|
||||
os.system("xset -display :0 s 21600")
|
||||
if os.path.isfile("updated.cfg"):
|
||||
print("NEW VER")
|
||||
os.remove("updated.cfg")
|
||||
sleep(5)
|
||||
else:
|
||||
client_id = "69b82a34d0fb40be80b020eae8e80f25"
|
||||
client_secret = "455575b0e3db44acbbfaa0c419bc3c10"
|
||||
|
||||
q = queue.Queue()
|
||||
|
||||
# import canvas
|
||||
|
||||
# Set the Spotify app's client ID and client secret
|
||||
# development client id and secret (SpotifyGUI)
|
||||
# client_id = "69b82a34d0fb40be80b020eae8e80f25"
|
||||
# client_secret = "455575b0e3db44acbbfaa0c419bc3c10"
|
||||
redirect_uri = "http://127.0.0.1:8888/callback"
|
||||
|
||||
client_id = "df61ecadf09941eb87e693d37f3ad178"
|
||||
client_secret = "ba97992d614e48d6b0d023998b2957cb"
|
||||
# embeeded client id and secret (SpotifyGUI 2)
|
||||
# client_id = "df61ecadf09941eb87e693d37f3ad178"
|
||||
# client_secret = "ba97992d614e48d6b0d023998b2957cb"
|
||||
|
||||
# Set the user's Spotify username
|
||||
username = "thebrandon45"
|
||||
@@ -70,7 +76,7 @@ spotify = spotipy.Spotify(auth_manager=oauth)
|
||||
# print(SpotifyOAuth.refresh_access_token(refresh_token=access_token))
|
||||
|
||||
bg_color = "#000000"
|
||||
# count = 0
|
||||
count = 0
|
||||
# wait_time = 6500
|
||||
# hotword = "magical"
|
||||
|
||||
@@ -163,6 +169,7 @@ def start_playback_on_device():
|
||||
spotify.transfer_playback(device_id=device_id)
|
||||
|
||||
def get_devices():
|
||||
global count
|
||||
# global count
|
||||
# global wait_time
|
||||
# count +=1
|
||||
@@ -170,6 +177,7 @@ def get_devices():
|
||||
# wait_time = 6500
|
||||
# elif count >= 69:
|
||||
# wait_time = 3600000
|
||||
count += 1
|
||||
list_of_devices = spotify.devices()
|
||||
|
||||
# if list_of_devices == "{'devices': []}":
|
||||
@@ -177,6 +185,10 @@ def get_devices():
|
||||
# loadSearching_Devices()
|
||||
# root.after(1000, get_devices)
|
||||
# else:
|
||||
if count > 210:
|
||||
unloadDevices_list()
|
||||
loadSleep()
|
||||
root.after(3600, get_devices)
|
||||
if spotify.current_playback() != None:
|
||||
# unloadSearching_Devices()
|
||||
unloadDevices_list()
|
||||
@@ -191,6 +203,10 @@ def get_devices():
|
||||
devices_list.insert(num_of_device, list_of_devices["devices"][num_of_device]["name"])
|
||||
root.after(8500, get_devices)
|
||||
|
||||
def wakeup():
|
||||
global count
|
||||
count = 0
|
||||
|
||||
# def wakeup():
|
||||
# global count
|
||||
# global wait_time
|
||||
@@ -331,6 +347,7 @@ frame_artist_song = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
||||
album_art_frame = ttk.Frame(root)
|
||||
lyrics_label_frame = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
||||
lyrics_label_frame.grid_propagate(0)
|
||||
sleep_frame = ttk.Frame(root, width=(1280/3), height=400, bg=bg_color)
|
||||
|
||||
root.grid_rowconfigure(0, weight=1)
|
||||
root.grid_rowconfigure(1, weight=1)
|
||||
@@ -344,10 +361,10 @@ lyrics_label_frame.grid_rowconfigure(0, weight=1)
|
||||
lyrics_label_frame.grid_columnconfigure(0, weight=1)
|
||||
|
||||
# Create the media control buttons and a text label
|
||||
play_button = ttk.Label(frame_artist_song, image=play_img, borderwidth=0)
|
||||
pause_button = ttk.Label(frame_artist_song, image=pause_img, borderwidth=0)
|
||||
next_button = ttk.Label(frame_artist_song, image=next_img, borderwidth=0)
|
||||
previous_button = ttk.Label(frame_artist_song, image=previous_img, borderwidth=0)
|
||||
play_button = ttk.Label(root, image=play_img, borderwidth=0)
|
||||
pause_button = ttk.Label(root, image=pause_img, borderwidth=0)
|
||||
next_button = ttk.Label(root, image=next_img, borderwidth=0)
|
||||
previous_button = ttk.Label(root, image=previous_img, borderwidth=0)
|
||||
artist_label = tk.Label(frame_artist_song, text="", font=("Helvetica", 24), wraplength=(1280/3), justify=ttk.CENTER, background=bg_color)
|
||||
song_label = tk.Label(frame_artist_song, text="", font=("Helvetica", 32), wraplength=(1280/3), justify=ttk.CENTER, background=bg_color)
|
||||
get_devices_button = tk.Button(root, text="Get Devices", command=get_devices)
|
||||
@@ -365,6 +382,7 @@ pause_button.bind("<Button-1>", lambda e:controlPause())
|
||||
next_button.bind("<Button-1>", lambda e:controlNext())
|
||||
previous_button.bind("<Button-1>", lambda e:controlPrevious())
|
||||
album_art_label.bind("<Button-1>", lambda e:likeSong())
|
||||
sleep_frame.bind("<Button-1>", lambda e:wakeup())
|
||||
# devices_list.bind("<Button-1>", lambda e:wakeup())
|
||||
|
||||
|
||||
@@ -383,15 +401,12 @@ def update_song_label():
|
||||
|
||||
root.after(200, get_devices)
|
||||
# Update the song label every 1 second
|
||||
else:
|
||||
if current_playback.get("item"):
|
||||
track_name = current_playback["item"]["name"]
|
||||
track_progress = current_playback["progress_ms"]
|
||||
playing_status = current_playback["is_playing"]
|
||||
track_progress_min = track_progress//(1000*60)%60
|
||||
track_progress_sec = (track_progress//1000)%60
|
||||
else:
|
||||
track_name = "Loading..."
|
||||
elif current_playback.get("item") is not None:
|
||||
track_name = current_playback["item"]["name"]
|
||||
track_progress = current_playback["progress_ms"]
|
||||
playing_status = current_playback["is_playing"]
|
||||
track_progress_min = track_progress//(1000*60)%60
|
||||
track_progress_sec = (track_progress//1000)%60
|
||||
if track_name == song_label.cget("text"):
|
||||
track_progress_formatted = ("{}:{:02d}".format(track_progress_min, track_progress_sec))
|
||||
progress_bar.config(value=track_progress)
|
||||
@@ -444,22 +459,24 @@ def update_song_label():
|
||||
root.after(500, update_song_label)
|
||||
if playing_status == True:
|
||||
play_button.grid_forget()
|
||||
pause_button.grid(row=3, column=1, pady=(100,0))
|
||||
pause_button.grid(row=3, column=1, pady=(0,20))
|
||||
elif playing_status == False:
|
||||
pause_button.grid_forget()
|
||||
play_button.grid(row=3, column=1, pady=(100,0))
|
||||
play_button.grid(row=3, column=1, pady=(0,20))
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
root.after(1000, get_devices)
|
||||
|
||||
def loadNow_playing():
|
||||
frame_artist_song.grid(row=0, column=1, rowspan=3, pady=(20,0))
|
||||
frame_artist_song.grid(row=0, column=1, rowspan=3, pady=(30,0), sticky="n")
|
||||
device_name_label.grid(row=0, column=1)
|
||||
artist_label.grid(row=2, column=1)
|
||||
song_label.grid(row=1, column=1)
|
||||
previous_button.grid(row=3, column=1, padx=(0,200), pady=(100,0))
|
||||
play_button.grid(row=3, column=1, pady=(100,0))
|
||||
next_button.grid(row=3, column=1, padx=(200,0), pady=(100,0))
|
||||
progress_bar.grid(row=3, column=0, columnspan=3)
|
||||
previous_button.grid(row=3, column=1, padx=(0,200), pady=(0,20))
|
||||
play_button.grid(row=3, column=1, pady=(0,20))
|
||||
next_button.grid(row=3, column=1, padx=(200,0), pady=(0,20))
|
||||
progress_bar.grid(row=3, column=0, columnspan=3, sticky="wse")
|
||||
album_art_frame.grid(row=0, column=0, rowspan=4)
|
||||
album_art_label.grid(sticky="w")
|
||||
lyrics_label_frame.grid(row=0, column=2, rowspan=4)
|
||||
@@ -490,6 +507,9 @@ def loadSearching_Devices():
|
||||
def unloadSearching_Devices():
|
||||
searching_for_devices_label.grid_forget()
|
||||
|
||||
def loadSleep():
|
||||
sleep_frame.grid()
|
||||
|
||||
|
||||
|
||||
# def recognize(recognizer, audio):
|
||||
|
||||
Reference in New Issue
Block a user