Commit 54df5452 by BellCodeEditor

auto save

parent 77457ef6
Showing with 28 additions and 11 deletions
a={"悟空":80,"小贝":100,"波奇":60,"诺依":0,}
a.clear()
print(a)
\ No newline at end of file
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
......@@ -11,16 +12,25 @@ 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('xuanni.ogg') #载入音乐
#pygame.mixer.music.load('wuli.ogg') #载入音乐
# pygame.mixer.music.load('xuanni.ogg') #载入音乐
# pygame.mixer.music.load('wuli.ogg') #载入音乐
volume=0.2
pygame.mixer.music.set_volume(volume)
click=0
play_button=stop_img
pygame.mixer.music.play() #播放音乐
num=-1
music_list=[]
path="C:\\Users\\XMBC\\Desktop\\test"
file1=os.listdir(path)
for i in file1:
if i[-4:]==".wav" or i[-4:]==".ogg":
music_list.append(i)
while True:
if pygame.mixer.music.get_busy()==False:
num+=1
if num>len(music_list)-1:
num=0
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play() #播放音乐
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -37,13 +47,16 @@ while True:
volume=0
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
click+=1
if click%2==0:
pygame.mixer.music.unpause()
play_button=stop_img
else:
pygame.mixer.music.pause()
play_button=play_img
if event.button==1: #鼠标左击
x,y=event.pos
if x>270 and x<370 and y>350 and y<450:
click+=1
if click%2==0:
pygame.mixer.music.unpause()
play_button=stop_img
else:
pygame.mixer.music.pause()
play_button=play_img
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
......
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