Commit daa559ab by BellCodeEditor

auto save

parent f9d63485
Showing with 24 additions and 3 deletions
...@@ -65,7 +65,10 @@ while True: ...@@ -65,7 +65,10 @@ while True:
click += 2 click += 2
else: else:
click += 1 click += 1
# 歌曲的时间
music = pygame.mixer.Sound(path + "\\" + music_list[num])
music_length = music1.get_length()
music_length = int(music_length)
if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲 if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲
num -= 1 num -= 1
if num < 0: if num < 0:
...@@ -77,13 +80,20 @@ while True: ...@@ -77,13 +80,20 @@ while True:
click += 2 click += 2
else: else:
click += 1 click += 1
# 歌曲的时间
if pygame.mixer.music.get_busy() == False: music1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_length = music1.get_length()
music_length = int(music_length)
if pygame.mixer.music.get_busy() == False: # 音乐是否正在播放
num += 1 num += 1
if num > len(music_list)-1: if num > len(music_list)-1:
num = 0 num = 0
pygame.mixer.music.load(path + "\\" + music_list[num]) pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play() # 播放音乐 pygame.mixer.music.play() # 播放音乐
# 歌曲的时间
music1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_length = music1.get_length()
music_length = int(music_length)
# 歌曲播放进度时间 # 歌曲播放进度时间
play_time = pygame.mixer.music.get_pos() play_time = pygame.mixer.music.get_pos()
...@@ -92,6 +102,14 @@ while True: ...@@ -92,6 +102,14 @@ while True:
play_m = play_time//60 # 分 play_m = play_time//60 # 分
play_s = play_time % 60 # 秒 play_s = play_time % 60 # 秒
info = str(play_m) + ":" + str(play_s) info = str(play_m) + ":" + str(play_s)
# 歌曲的时间长度
music_m = music_length//60
music_s = music_length%60
if music_s < 10:
music_s = "0"+str(music_s)
info2 = str(music_m)+":"+str(music_s)
# 旋转后的唱盘图片 # 旋转后的唱盘图片
new_logo = pygame.transform.rotate(logo_img, 90) new_logo = pygame.transform.rotate(logo_img, 90)
newRect = new_logo.get_rect(center=(320, 200)) newRect = new_logo.get_rect(center=(320, 200))
...@@ -107,5 +125,7 @@ while True: ...@@ -107,5 +125,7 @@ while True:
# 绘制时间进度 # 绘制时间进度
scoreSurf = basic_font.render(info, True, (255, 255, 255)) scoreSurf = basic_font.render(info, True, (255, 255, 255))
screen.blit(scoreSurf, (120,440)) screen.blit(scoreSurf, (120,440))
scoreSurf2 = basic_font.render("/" + info2, True, (0, 0, 0))
screen.blit(scoreSurf2, (170,440))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment