This commit is contained in:
Lukas Schulz 2020-12-20 14:08:24 +01:00
parent 6e7af85276
commit 225a04a4fd

19
main.py
View file

@ -42,6 +42,9 @@ is_scrolling_art = False
cover_art_offset_x = 0 cover_art_offset_x = 0
cover_art_offset_y = 96 cover_art_offset_y = 96
last_cover_art = Image.new('RGB',(32,32),color='white')
las_song = ''
token = None #oauth2.SpotifyOAuth(username, scope, client_id, client_secret, redirect_uri) token = None #oauth2.SpotifyOAuth(username, scope, client_id, client_secret, redirect_uri)
#token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri) #token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
@ -99,11 +102,19 @@ def showImage(image, offset_x = 0, offset_y = 0):
def drawCanvas(): def drawCanvas():
canvas = Image.new('RGB', (192, 128), color = 'black') canvas = Image.new('RGB', (192, 128), color = 'black')
global last_song
was_playing = is_playing was_playing = is_playing
cover_art = get_track() cover_art = get_track()
global is_scrolling_art global is_scrolling_art
if (cover_art is None): if (cover_art is None):
return return
if not (last_song == song_name):
last_cover_art = cover_art
if(was_playing and not is_playing): if(was_playing and not is_playing):
is_scrolling_art = True is_scrolling_art = True
scroll = threading.Thread(target=scrollDownSongInfo) scroll = threading.Thread(target=scrollDownSongInfo)
@ -135,9 +146,9 @@ def drawCanvas():
showImage(canvas) showImage(canvas)
def scrollDownSongInfo(offset_x=0,offset_y=96): def scrollDownSongInfo(offset_x=0,offset_y=96, song_name=song_name, artist_name=artist_name, cover_art=get_track()):
global is_scrolling_art global is_scrolling_art
cover_art = get_track() #cover_art = get_track()
if (cover_art is None): if (cover_art is None):
return return
for i in range(33): for i in range(33):
@ -151,9 +162,9 @@ def scrollDownSongInfo(offset_x=0,offset_y=96):
time.sleep(0.001) time.sleep(0.001)
is_scrolling_art = False is_scrolling_art = False
def scrollUpSongInfo(offset_x=0, offset_y=96): def scrollUpSongInfo(offset_x=0, offset_y=96, song_name=song_name, artist_name=artist_name, cover_art=get_track()):
global is_scrolling_art global is_scrolling_art
cover_art = get_track() #cover_art = get_track()
if (cover_art is None): if (cover_art is None):
return return
for i in range(33): for i in range(33):