Commit 513888b4 by BellCodeEditor

save project

parent 49d45269
Showing with 9 additions and 2 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
...@@ -16,7 +17,13 @@ volume = 0.2 ...@@ -16,7 +17,13 @@ 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
musiclist=['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg'] musiclist=[]
path='C:\\Users\\Hanson Zhang\\Desktop\\音乐播放器'
filelist=os.listdir(path)
for file in filelist:
if file[-3:]=='wav' or file[-3:]=='ogg':
musiclist.append(file)
num=-1 num=-1
while True: while True:
...@@ -52,7 +59,7 @@ while True: ...@@ -52,7 +59,7 @@ while True:
num+=1 num+=1
if num>len(musiclist)-1: if num>len(musiclist)-1:
num=0 num=0
pygame.mixer.music.load(musiclist[num]) pygame.mixer.music.load(path+'\\'+musiclist[num])
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