-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZMP.py
75 lines (59 loc) · 2.02 KB
/
ZMP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
from os import walk
import os.path
import sys
import pygame
from pygame import mixer
#init mixer process
mixer.init()
#get files
songs = []
os.chdir(os.getcwd() + '/songs')
for (dirpath, dirnames, filenames) in walk(os.getcwd()):
songs.extend(filenames)
break
it = 0
#player
while True:
song = songs[it]
mixer.music.load(song) #load song
mixer.music.set_volume(0.5) #set volume
mixer.music.play() #play
playing = 1
while True:
os.system('cls')
print("-----------------------------------------")
print("---------- ZABE MUSIC PLAYER ----------")
print("------------------------------------------")
print(" Current song: " + song + "")
print(" A(<<) (>>)D")
print(" Volume: " + str(int(100*mixer.music.get_volume())) + "%· W(++) (--)S")
print(" P: play/pause")
print(" E: exit")
print("-----------------------------------------")
print(" Current song: " + song)
print(" Songs queued: " + str(len(songs)))
action = input(">>> ")
if action == 'P' or action == 'p': #play,pause
if playing:
mixer.music.pause()
playing = 0
else:
mixer.music.unpause()
playing = 1
elif action == 'W' or action == 'w': #volume up
v = mixer.music.get_volume()
mixer.music.set_volume(v + 0.1)
elif action == 'S' or action == 's': #volume down
v = mixer.music.get_volume()
mixer.music.set_volume(v- 0.1)
elif action == 'A' or action == 'a': #previous song
it = (it - 1)%len(songs)
break
elif action == 'D' or action == 'd': #next song
it = (it + 1)%len(songs)
break
elif action == 'E' or action == 'e': #stop
mixer.music.stop()
print("Closing...")
sys.exit(0)