Commit db4425d6 by BellCodeEditor

auto save

parent 80548662
Showing with 70 additions and 4 deletions
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
......@@ -11,9 +12,19 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲4.ogg')
my_font=pygame.font.Font("neuropol.ttf",18)
volume=0.2
pygame.mixer.music.set_volume(volume)
play_botton=stop_img
k=0
angle=0
music_list=[]
num=-1
path=r"C:\Users\admin\Desktop\text"
file_list=os.listdir(path)
for i in file_list:
if i[-4:]=='.wav' or i[-4:]=='.ogg':
music_list.append(i)
while True:
for event in pygame.event.get():
if event.type==locals.QUIT:
......@@ -29,13 +40,68 @@ while True:
if volume<0:
volume=0
pygame.mixer.music.set_volume(volume)
if pygame.mixer.get_busy()==False:
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:
k+=1
if k%2==0:
pygame.mixer.music.unpause()
play_botton=stop_img
else:
pygame.mixer.music.pause()
play_botton=play_img
if x>=120 and x<=220 and y>=350 and y<=400:
num-=1
num%=4
music=pygame.mixer.music.Sound(path+'\\'+music_list[num])
music_length=music.get_length()
pygame.mixer.music.play()
k=0
play_botton=stop_img
if x>=420 and x<=520 and y>=350 and y<=400:
num+=1
num%=4
music=pygame.mixer.music.Sound(path+'\\'+music_list[num])
music_length=music.get_length()
pygame.mixer.music.play()
k=0
play_botton=stop_img
if pygame.mixer.music.get_busy()==False:
num+=1
if num>len(music_list):
num=0
music=pygame.mixer.music.Sound(path+'\\'+music_list[num])
music_length=music.get_length()
pygame.mixer.music.play()
new_logo=pygame.transform.rotate(logo_img,angle)
newreat=new_logo.get_rect(center=[320,200])
pos=(newreat[0],newreat[1])
if k%2==0:
angle+=1
play_time=pygame.mixer.music.get_pos()
play_time=int(play_time/1000)
play_m=play_time//60
paly_s=play_time%60
info=str(play_m)+":"+str(paly_s)
if paly_s<10:
info="0"+str(play_m)+":"+str(paly_s)
test=my_font.render(info,True,(255,255,255))
music_length=int(music_length/1000)
music_length_m=music_length//60
music_length_s=music_length%60
info1=str(play_m)+":"+str(paly_s)
if music_length_s<10:
info="0"+str(play_m)+":"+str(paly_s)
test1=my_font.render(info1,True,(0,0,0))
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(stop_img, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图
screen.blit(play_botton, (270, 330)) # 暂停按钮
screen.blit(new_logo, pos) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(test,(80,300))
screen.blit("/"+test1,(100,300))
# 刷新画面
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