Commit c92d935c by BellCodeEditor

save project

parent efacc141
Showing with 14 additions and 4 deletions
...@@ -12,6 +12,7 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -12,6 +12,7 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮 last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮 next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮 logo_img = pygame.image.load('logo.png') # 下一曲按钮
basiic_font=pygame.font.Font('neuropol.ttf',14)
music_list = [] music_list = []
path = 'C:\\Users\\MK016\\Documents\\pygame_lesson6_diy1' path = 'C:\\Users\\MK016\\Documents\\pygame_lesson6_diy1'
...@@ -23,6 +24,7 @@ for i in filelist: ...@@ -23,6 +24,7 @@ for i in filelist:
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0 click = 0
play_time=0
play_button = stop_img play_button = stop_img
angle=0 angle=0
while True: while True:
...@@ -81,14 +83,19 @@ while True: ...@@ -81,14 +83,19 @@ while True:
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.play()
play_time=pygame.mixer.music.get_pos()
play_time=int(play_time/1000)
m=play_time//60
s=play_time%60
info=str(m)+':'+str(s)
new_logo=pygame.transform.rotate(logo_img,angle) new_logo=pygame.transform.rotate(logo_img,angle)
newRect=new_logo.get_rect(center=(320,200)) newRect=new_logo.get_rect(center=(320,200))
pos=(newRect[0],newRect[1]) pos=(newRect[0],newRect[1])
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
if play_button==stop_img: if play_button==stop_img:
angle+=10 angle+=3
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
...@@ -97,4 +104,6 @@ while True: ...@@ -97,4 +104,6 @@ while True:
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面 # 刷新画面
s1=basiic_font.render(info,True,(255,255,255))
screen.blit(s1,(120,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