Commit 9c3e8d84 by BellCodeEditor

save project

parent 192abae7
Showing with 47 additions and 6 deletions
......@@ -14,7 +14,7 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
myfont = pygame.font.Font('neuropol.ttf',15)
music_list = []
path = r"C:\Users\Administrator\Desktop\新建文件夹 (2)"
path = "C:\\Users\\Administrator\\Desktop\\新建文件夹 (2)"
filelist = os.listdir(path)
num = -1
for i in filelist:
......@@ -25,13 +25,26 @@ pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
angle = 1
music_1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_time = music_1.get_length()
music_time = int(music_time)
music_m = music_time // 60
music_s = music_time % 60
if music_s < 10:
music_s = "0"+str(music_s)
else:
music_s = str(music_s)
while True:
play_time = pygame.mixer.music.get_pos()
play_time = int(play_time/1000)
p_m = play_time // 60
p_s = play_time % 60
info = str(p_m)+":"+str(p_s)
text = myfont.render(info,True,(0,0,0))
if p_s < 10:
p_s = "0"+str(p_s)
else:
p_s = str(p_s)
new_img = pygame.transform.rotate(logo_img,angle)
new_rect = new_img.get_rect(center = (320,190))
if click % 2 == 0:
......@@ -66,6 +79,7 @@ while True:
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 420 and x < 520 and y > 350 and y < 400: # 下一曲
num += 1
if num > len(music_list) - 1:
......@@ -77,7 +91,15 @@ while True:
click += 2
else:
click += 1
music_ = pygame.mixer.Sound(path + "\\" + music_list[num])
music_time = music_.get_length()
music_time = int(music_time)
music_m = music_time // 60
music_s = music_time % 60
if music_s < 10:
music_s = "0"+str(music_s)
else:
music_s = str(music_s)
if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲
num -= 1
if num < 0:
......@@ -89,20 +111,38 @@ while True:
click += 2
else:
click += 1
music_ = pygame.mixer.Sound(path + "\\" + music_list[num])
music_time = music_.get_length()
music_time = int(music_time)
music_m = music_time // 60
music_s = music_time % 60
if music_s < 10:
music_s = "0"+str(music_s)
else:
music_s = str(music_s)
if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(music_list)-1:
num = 0
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
music_1 = pygame.mixer.Sound(path + "\\" + music_list[num])
music_time = music_1.get_length()
music_time = int(music_time)
music_m = music_time // 60
music_s = music_time % 60
if music_s < 10:
music_s = "0"+str(music_s)
else:
music_s = str(music_s)
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(new_img, (l_x, l_y)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
info = str(p_m)+":"+p_s+"/"+ str(music_m)+":"+music_s
text = myfont.render(info,True,(0,0,0))
screen.blit(text,(40,440))
# 刷新画面
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