Commit dcb0866d by BellCodeEditor

save project

parent 2fd23886
Showing with 40 additions and 7 deletions
...@@ -11,16 +11,13 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -11,16 +11,13 @@ 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 logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲4.ogg')
basic_font=pygame.font.Font("neuropol.ttf",14) basic_font=pygame.font.Font("neuropol.ttf",14)
w = [] w = []
qq="C:\\Users\\86130\\Desktop\\text" qq="C:\\Users\\86130\\Desktop\\text"
l=os.listdir(qq) l=os.listdir(qq)
for i in l: for i in l:
if i[-4:]==".wav" or i[-4:]==".ogg": if i[-4:]==".wav" or i[-4:]==".ogg":
w.append(i) w.append(i)
angle=0 angle=0
a=0.2 a=0.2
pygame.mixer.music.set_volume(a) pygame.mixer.music.set_volume(a)
...@@ -28,9 +25,9 @@ ades = 2 ...@@ -28,9 +25,9 @@ ades = 2
b = stop_img b = stop_img
x,y = (0,0) x,y = (0,0)
m = -1 m = -1
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type==locals.QUIT: if event.type==locals.QUIT:
exit() exit()
if event.type==locals.KEYDOWN: if event.type==locals.KEYDOWN:
...@@ -45,16 +42,34 @@ while True: ...@@ -45,16 +42,34 @@ while True:
a=0 a=0
pygame.mixer.music.set_volume(a) pygame.mixer.music.set_volume(a)
if event.type == locals.MOUSEBUTTONDOWN: if event.type == locals.MOUSEBUTTONDOWN:
if event.button==1:
x,y=event.pos
if x>270 and x<370 and y >350 and y<450: if x>270 and x<370 and y >350 and y<450:
ades += 1 ades += 1
if ades % 2 == 1: if ades % 2 == 1:
pygame.mixer.music.pause()
b = play_img b = play_img
pygame.mixer.music.pause()
else: else:
b = stop_img
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
if x>420 and x<520 and y>350 and y<400:
m=m+1
if m>len(w)-1:
m=0
print(len(w))
pygame.mixer.music.load(qq+"\\"+w[m])
pygame.mixer.music.play()
ades=0
b = stop_img b = stop_img
info=str(play_m)+":"+str(play_s)
if x>120 and y>350 and x<520 and y>240 and y<400: music=pygame.mixer.Sound(qq+"\\"+w[m])
music1=music.get_length()
music1=int(music1)
musics=music1%60
musicm=music1//60
info2=str(musicm)+":"+str(musics)
newRect=new_logo.get_rect(center=(320,200))
if x>120 and x<220 and y>350 and y<400:
m=m-1 m=m-1
if m<0: if m<0:
m=len(w)-1 m=len(w)-1
...@@ -62,6 +77,14 @@ while True: ...@@ -62,6 +77,14 @@ while True:
pygame.mixer.music.play() pygame.mixer.music.play()
ades=0 ades=0
b = stop_img b = stop_img
info=str(play_m)+":"+str(play_s)
music=pygame.mixer.Sound(qq+"\\"+w[m])
music1=music.get_length()
music1=int(music1)
musics=music1%60
musicm=music1//60
info2=str(musicm)+":"+str(musics)
newRect=new_logo.get_rect(center=(320,200))
if pygame.mixer.music.get_busy()==False: if pygame.mixer.music.get_busy()==False:
m += 1 m += 1
if m > len(w)-1: if m > len(w)-1:
...@@ -73,7 +96,15 @@ while True: ...@@ -73,7 +96,15 @@ while True:
play_time=int(play_time/1000) play_time=int(play_time/1000)
play_m=play_time//60 play_m=play_time//60
play_s=play_time%60 play_s=play_time%60
if play_s<10:
play_s="0"+str(play_s)
info=str(play_m)+":"+str(play_s) info=str(play_m)+":"+str(play_s)
music=pygame.mixer.Sound(qq+"\\"+w[m])
music1=music.get_length()
music1=int(music1)
musics=music1%60
musicm=music1//60
info2=str(musicm)+":"+str(musics)
newRect=new_logo.get_rect(center=(320,200)) newRect=new_logo.get_rect(center=(320,200))
if ades%2==0: if ades%2==0:
angle+=1 angle+=1
...@@ -85,5 +116,7 @@ while True: ...@@ -85,5 +116,7 @@ while True:
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
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()
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