Commit 4b47c6a2 by BellCodeEditor

save project

parent ab8dc4b6
Showing with 9 additions and 11 deletions
import pygame import pygame
from pygame import locals
import os import os
from pygame import locals
files=os.listdir("C:\\Users\\Administrator\\Desktop\\新建文件夹")
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -14,12 +14,13 @@ next_img = pygame.image.load('next.png') # 下一曲按钮 ...@@ -14,12 +14,13 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮 logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐 # 载入音乐
volume = 0.5 # 载入音乐
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
#path=os.listdir("C:\\Users\\Administrator\\Desktop\\Music")
path=os.listdir("C:\\Users\\Administrator\\Documents\\pygame_lesson5_diy2")
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:
...@@ -52,12 +53,9 @@ while True: ...@@ -52,12 +53,9 @@ while True:
pygame.mixer.music.pause() pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
for j in path: for i in files:
#if j[-4:] == ".mp3": if i[-4:]==".mp3" or ".wav" or ".ogg":
if j[-4:] == ".wav": pygame.mixer.music.load(i)
print(j)
#pygame.mixer.music.load("C:\\Users\\Administrator\\Desktop\\Music"+"\\"+j) # 载入音乐
pygame.mixer.music.load("C:\\Users\\Administrator\\Documents\\pygame_lesson5_diy2"+"\\"+j) # 载入音乐
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