diff --git a/my_music.py b/my_music.py index 06621a1..41ec2e6 100644 --- a/my_music.py +++ b/my_music.py @@ -83,10 +83,18 @@ while True: num = 0 pygame.mixer.music.load(path + "\\" + music_list[num]) pygame.mixer.music.play() + #获取时间 + play_time = pygame.mixer.music.get_pos()#毫秒 + play_time = int(play_time/1000)#秒 + play_m = play_time//60 + play_s = play_time%60 + info = str(play_m)+":"+str(play_s) new_logo = pygame.transform.rotate(logo_img, angle) - # 校正旋转图片的中心点 - if play_button == stop_img: + if play_button == stop_img: angle -= 1 + + # 校正旋转图片的中心点 + newRect = new_logo.get_rect(center=(320, 200)) position = (newRect[0], newRect[1]) angle -= 1 @@ -96,5 +104,11 @@ while True: screen.blit(new_logo, position) # 中间logo图 screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(next_img, (420, 350)) # 下一曲 + basic_font = pygame.font.Font('neuropol.ttf',14) + + #绘制时间 + time = basic_font.render(info,True,(255,255,255)) + screen.blit(time,(120,440)) + # 刷新画面 pygame.display.update() \ No newline at end of file