From f3038a7242975306dd65a1247032b528af9ca5bb Mon Sep 17 00:00:00 2001 From: Lukas Schulz Date: Sun, 20 Dec 2020 13:50:39 +0100 Subject: [PATCH] yes. --- main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 2199f4a..95b922c 100644 --- a/main.py +++ b/main.py @@ -37,6 +37,8 @@ cache_path="/home/pi/.cache-"+username is_playing = False +is_scrolling_art = False + cover_art_offset_x = 0 cover_art_offset_y = 96 @@ -99,12 +101,16 @@ def drawCanvas(): canvas = Image.new('RGB', (192, 128), color = 'black') was_playing = is_playing cover_art = get_track() - if (cover_art is None): + global is_scrolling_art + if (cover_art is None or is_scrolling_art): return if(was_playing and not is_playing): + is_scrolling_art = True scroll = threading.Thread(target=scrollDownSongInfo) scroll.start() + if(not was_playing and is_playing): + is_scrolling_art = True scroll = threading.Thread(target=scrollUpSongInfo) scroll.start() if(is_playing): @@ -128,6 +134,7 @@ def drawCanvas(): showImage(canvas) def scrollDownSongInfo(offset_x=0,offset_y=96): + global is_scrolling_art cover_art = get_track() if (cover_art is None): return @@ -140,8 +147,10 @@ def scrollDownSongInfo(offset_x=0,offset_y=96): song_info_canvas.paste(cover_art,(0,i)) showImage(song_info_canvas, offset_x, offset_y) time.sleep(0.001) + is_scrolling_art = False def scrollUpSongInfo(offset_x=0, offset_y=96): + global is_scrolling_art cover_art = get_track() if (cover_art is None): return @@ -154,6 +163,7 @@ def scrollUpSongInfo(offset_x=0, offset_y=96): song_info_canvas.paste(cover_art,(0,(33-i))) showImage(song_info_canvas, offset_x, offset_y) time.sleep(0.001) + is_scrolling_art = False def scrolling_text(text,offset_x=0,offset_y=0): scroll_frame_time = (8/2)/(font.getsize(text)[0]-160)