Commit a0af5c5e by BellCodeEditor

save project

parent 1abe21e7
Showing with 14 additions and 9 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os import os
sd=[]
path="C:\\Users\\Administrator\\Desktop\\test"
filelist=os.listdir(path)
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
...@@ -15,11 +13,11 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -15,11 +13,11 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮 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') # 下一曲按钮
music_list=[] sd=[]
path="C:\\Users\\Administrator\\Desktop\\test" path="C:\\Users\\Administrator\\Desktop\\test"
cb=os.listdir(path) cb=os.listdir(path)
for i in cb: for i in cb:
if i[-4:]==".wav" or i[-4:]=="ogg": if i[-4:]==".wav" or i[-4:]==".ogg":
sd.append(i) sd.append(i)
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
...@@ -61,13 +59,20 @@ while True: ...@@ -61,13 +59,20 @@ while True:
if x>120 and x<220 and y>350 and y<400: if x>120 and x<220 and y>350 and y<400:
num-=1 num-=1
if num<0: if num<0:
num=len(path+"\\"sd)-1 num=len(sd)-1
click=0 click=0
play_img=stop_img play_img=stop_img
pygame.mixer.music.load(path+"\\"sd[num]) pygame.mixer.music.load(sd[num])
pygame.mixer.music.play()
if x>420 and x<520 and y>350 and y<400:
num+=1
if num>len(sd)-1:
num=0
print(sd)
click=0
play_img=stop_img
pygame.mixer.music.load(sd[num])
pygame.mixer.music.play() pygame.mixer.music.play()
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num+=1 num+=1
if num>len(sd)-1: if num>len(sd)-1:
......
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