Commit 017d1514 by BellCodeEditor

save project

parent b95b291a
Showing with 9 additions and 8 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -13,20 +12,22 @@ last_img = pygame.image.load('last.png') # 上一曲按钮 ...@@ -13,20 +12,22 @@ 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_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐 # 载入音乐 # 载入音乐
# 载入音乐
m=[]
h="C:\\Users\\lenovo\Desktop\\新建文件夹 (2)" h="C:\\Users\\lenovo\Desktop\\新建文件夹 (2)"
fillelist=os.listdir(h) fillelist=os.listdir(h)
for i in fillelist:
if i[-4:]==".wav"or i[-4:]==".ogg":
u=-1
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0 click = 0
play_button = stop_img play_button = stop_img
while True: while True:
for i in fillelist:
if i[-4:]!=".wav"and i[-4:]!=".ogg":
u+=1
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
...@@ -59,9 +60,9 @@ while True: ...@@ -59,9 +60,9 @@ while True:
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
u+=1 u+=1
if u > len(m)-1: if u > len(fillelist)-1:
u=0 u=0
pygame.mixer.music.load(p+"\\"+m[u]) pygame.mixer.music.load(h+"\\"+fillelist[u])
pygame.mixer.music.play() pygame.mixer.music.play()
# 绘制画面 # 绘制画面
......
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