Commit ee70709e by BellCodeEditor

auto save

parent 16285e59
Showing with 35 additions and 3 deletions
......@@ -13,8 +13,17 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐
pygame.mixer.music.load('歌曲4.ogg') # 载入音乐
#pygame.mixer.music.load('歌曲4.ogg') # 载入音乐
#使用列表存储音乐filelist
music_list=['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg']
# music_list=[] #空列表
# pat=#文件路径
# #获取文件里的所有文件
# #对获取到的文件进行遍历
# #判断文件是否为音乐文件
# #添加到列表中append()方法-在列表末尾增添圆顺
num=-1#设置num的初始值,让音乐从第一首开始播放
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
......@@ -39,7 +48,9 @@ while True:
# 按下鼠标
if event.type == locals.MOUSEBUTTONDOWN:
# 次数增加
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:
play_button = stop_img
......@@ -47,8 +58,29 @@ while True:
else:
play_button = play_img
pygame.mixer.music.pause()
if x>120 and x<220 and y>350 and y<400:#判断鼠标是否点击了上一曲按钮
num-=1#切换到上一曲歌曲的位置索引
if num<0:#判断是否超出了第一首
num=len(music_list)-1#歌曲切换到最后一首
pygame.mixer.music.load(music_list[num])#加载音乐
pygame.mixer.music.play()#播放音乐
play_button=stop_img#设置为暂停播放按钮的造型
click=0#鼠标点击的次数归零
if x>420 and x<520 and y>350 and y<400:#判断鼠标是否点击了下一曲按钮
num+=1#切换到下一曲歌曲的位置索引
if num>len(music_list)-1:#-1判断是否超出了最后一首
num=0#歌曲切换到第一首
pygame.mixer.music.load(music_list[num])#加载音乐
#播放音乐
pygame.mixer.music.play()
play_button=stop_img#设置为暂停播放按钮的造型
click=0#鼠标点击的次数归零
if pygame.mixer.music.get_busy() == False:
num+=1#播放下一首
if num>len(music_list)-1:#判断num是否超出列表索引
num=0#让音乐回到第一首的位置进行播放
pygame.mixer.music.load(music_list[num])#加载音乐
#播放音乐
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