Commit 7be82665 by BellCodeEditor

save project

parent 0d04e23e
File added
import pygame import pygame
from pygame import locals from pygame import locals
import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -11,17 +11,103 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -11,17 +11,103 @@ 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
nerttf=pygame.font.Font('neuropol.ttf',14)
asd=[]
qwe='C:\\Users\\EDY\\Desktop\\test'
iop=os.listdir(qwe)
for i in iop:
if i[-4:] ==".wav" or i[-4:]==".ogg":
asd.append(i)
zxc=-1
j=0.5
pygame.mixer.music.set_volume(j)
c=0
tb=stop_img
ingh=0
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.key==locals.K_UP:
j=j+0.1
pygame.mixer.music.set_volume(j)
if j>1:
j=1
if event.key==locals.K_DOWN:
j=j-0.1
pygame.mixer.music.set_volume(j)
if j<0:
j=0
if event.type==locals.MOUSEBUTTONDOWN:
if event.button==1:
x,y=event.pos
if x>270 and x<370 and y>330 and y<430:
c+=1
if c%2==0:
pygame.mixer.music.unpause()
tb=stop_img
else:
pygame.mixer.music.pause()
tb=play_img
if x>120 and x<220 and y>350 and y<400:
zxc-=1
if zxc<0:
zxc=len(asd)-1
pygame.mixer.music.load(qwe+'\\'+asd[zxc])
pygame.mixer.music.play()
c=0
tb=stop_img
music1=pygame.mixer.Sound(qwe+'\\'+asd[zxc])
music_length=music1.get_length()
music_length=int(music_length)
if x>420 and x<520 and y>350 and y<400:
zxc+=1
if zxc>len(asd)-1:
zxc=0
pygame.mixer.music.load(qwe+'\\'+asd[zxc])
pygame.mixer.music.play()
c=0
tb=stop_img
music1=pygame.mixer.Sound(qwe+'\\'+asd[zxc])
music_length=music1.get_length()
music_length=int(music_length)
if pygame.mixer.music.get_busy()==False:
zxc+=1
if zxc>len(asd)-1:
zxc=0
pygame.mixer.music.load(qwe+'\\'+asd[zxc])
pygame.mixer.music.play()
music1=pygame.mixer.Sound(qwe+'\\'+asd[zxc])
music_length=music1.get_length()
music_length=int(music_length)
play_time=pygame.mixer.music.get_pos()
play_time=int(play_time/1000)
play_f=play_time//60
play_m=play_time%60
info=str(play_f)+':'+str(play_m)
muc_f=music_length//60
muc_m=music_length%60
info1='/'+str(muc_f)+':'+str(muc_m)
ingh_img=pygame.transform.rotate(logo_img,ingh)
if c%2==0:
ingh+=1
re_j=ingh_img.get_rect(center=(320,200))
zb=(re_j[0],re_j[1])
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(stop_img, (270, 330)) # 暂停按钮 screen.blit(tb, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图 screen.blit(ingh_img, zb) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
xxx=nerttf.render(info,True,(255,255,255))
screen.blit(xxx,(99,440))
xxx1=nerttf.render(info1,True,(255,255,255))
screen.blit(xxx1,(140,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