Commit 0bbb90a9 by BellCodeEditor

save project

parent 8a84ac6d
File deleted
File added
File deleted
File added
...@@ -5,7 +5,8 @@ import os ...@@ -5,7 +5,8 @@ import os
pygame.init() pygame.init()
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
f1=pygame.font.Font('neuropol.ttf',15)
f2=pygame.font.Font('neuropol.ttf',15)
bg_img = pygame.image.load('background.png') # 背景图 bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮 play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮 stop_img = pygame.image.load('stop.png') # 暂停按钮
...@@ -18,7 +19,7 @@ path = "C:\\Users\\xxx\\Documents\\pygame_lesson6_diy2" ...@@ -18,7 +19,7 @@ path = "C:\\Users\\xxx\\Documents\\pygame_lesson6_diy2"
filelist = os.listdir(path) filelist = os.listdir(path)
num = -1 num = -1
for i in filelist: for i in filelist:
if i[-4:] == ".mp3" or i[-4:] == ".m4a": if i[-4:] == ".ogg":
music_list.append(i) music_list.append(i)
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
...@@ -64,7 +65,9 @@ while True: ...@@ -64,7 +65,9 @@ while True:
click += 2 click += 2
else: else:
click += 1 click += 1
music=pygame.mixer.Sound(path+'\\'+music_list[num])
music_time=music.get_length()
music_time=int(music_time)
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:
...@@ -76,6 +79,9 @@ while True: ...@@ -76,6 +79,9 @@ while True:
click += 2 click += 2
else: else:
click += 1 click += 1
music=pygame.mixer.Sound(path+'\\'+music_list[num])
music_time=music.get_length()
music_time=int(music_time)
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num += 1 num += 1
...@@ -83,7 +89,24 @@ while True: ...@@ -83,7 +89,24 @@ while True:
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()
music=pygame.mixer.Sound(path+'\\'+music_list[num])
music_time=music.get_length()
music_time=int(music_time)
play_time=pygame.mixer.music.get_pos()
play_time=int(play_time//1000)
play_time_m=play_time//60
play_time_s=play_time%60
if play_time_s<10:
play_time_s='0'+str(play_time_s)
info1=str(play_time_m)+':'+str(play_time_s)
music_m=music_time//60
music_s=music_time%60
info2=str(music_m)+':'+str(music_s)
new_logo = pygame.transform.rotate(logo_img, angle) new_logo = pygame.transform.rotate(logo_img, angle)
if play_button==stop_img : if play_button==stop_img :
angle += 1 angle += 1
...@@ -95,4 +118,8 @@ while True: ...@@ -95,4 +118,8 @@ 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))
myf1=f1.render(info1,1,(255,255,255))
screen.blit(myf1,(120,440))
myf2=f2.render('/'+info2,1,(0,0,0))
screen.blit(myf2,(170,440))
pygame.display.update() pygame.display.update()
\ No newline at end of file
File deleted
File added
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