Commit 813758e0 by BellCodeEditor

auto save

parent 9298a7b6
File deleted
j.jpg

50.8 KB

import pygame
from pygame import locals
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
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('605.mp3')
v=0.1
pygame.mixer.music.set_volume(v)
while True:
import pygame
import os
from pygame import locals
wq=r'C:\Users\Administrator\Desktop\test'
d=os.listdir(wq)
print(d)
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((720, 720))
# 载入图片、资源
bg_img = pygame.image.load('j.jpg') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
v=1
c=0
num=-1
music=[]
for i in d:
if i[-4:]=='.wav':
music.append(i)
pygame.mixer.music.set_volume(v)
f=stop_img
while True:
for event in pygame.event.get():
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:
c+=1
if c%2==0:
pygame.mixer.music.unpause()
f=stop_img
else:
pygame .mixer.music.pause()
f=play_img
if x>120 and x<220 and y>350 and y<400:
num-=1
if num<0:
num=len(music)-1
pygame.mixer.music.load(wq+'\\'+music[num])
pygame.mixer.music.play()
click=0
f=stop_img
if x>420 and x<520 and y>350 and y<400:
num+=1
if num>len(music)-1:
num=0
pygame.mixer.music.load(wq+'\\'+music[num])
pygame.mixer.music.play()
click=0
f=stop_img
if event.type==locals.QUIT:
exit()
if event.type==locals.KEYDOWN:
......@@ -30,14 +65,19 @@ while True:
v=0
pygame.mixer.music.set_volume(v)
if pygame.mixer.music.get_busy()==False:
num+=1
if num>len(music)-1:
num=0
pygame.mixer.music.load(wq+'\\'+music[num])
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
# 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间lohog图
# 中间flag图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(f, (270, 330))
# 刷新画面
pygame.display.update()
File added
File added
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