Commit aad7a467 by BellCodeEditor

auto save

parent c0ab8cfa
last.png

3.79 KB

logo.png

40.9 KB

File added
next.png

3.87 KB

play.png

12.1 KB

import pygame
from pygame import locals
import os
pygame.init()
volume=0.5
screen=pygame.display.set_mode((640,480))
last=pygame.image.load('last.png')
play2=pygame.image.load('play.png')
next1=pygame.image.load('next.png')
background=pygame.image.load('background.png')
logo=pygame.image.load('logo.png')
stop=pygame.image.load('stop.png')
pygame.mixer.music.set_volume(volume)
click=0
umn=-1
music=[]
path="C:\\Users\\Lenovo\\Desktop\\level3-lesson4-diy1"
fa=os.listdir(path)
for i in fa:
if i[-4:]==".wav" or i[-4:]==".ogg":
music.append(i)
play1=stop
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_UP:
volume+=0.1
if volume>1:
volume=1
pygame.mixer.music.set_volume(volume)
if event.key==locals.K_DOWN:
volume-=0.1
if volume<0:
volume=0
pygame.mixer.music.set_volume(volume)
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:
pygame.mixer.music.unpause()
play1=stop
else:
pygame.mixer.music.pause()
play1=play2
if pygame.mixer.music.get_busy()==False:
umn+=1
if umn>len(music)-1:
umn=0
pygame.mixer.music.load(path+"\\"+music[umn])
pygame.mixer.music.play()
screen.blit(background,(0,0))
screen.blit(play1,(270,330))
screen.blit(logo,(170,60))
screen.blit(last,(120,350))
screen.blit(next1,(420,350))
pygame.display.update()
stop.png

11.6 KB

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