-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsong_api.py
49 lines (33 loc) · 901 Bytes
/
song_api.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
from pygame import mixer
import os
def play_this(string):
mixer.init()
mixer.music.load(string)
mixer.music.play()
print("song playing : ",string)
while True:
k = input()
if k == "stop":
mixer.music.stop()
return
if k == "pause":
print("\t paused. Enter play to inpause")
mixer.music.pause()
if k == "play":
print("\t unpaused")
mixer.music.unpause()
print(os.getcwd())
os.chdir("//home//itachi//Music")
while True:
list_songs = os.listdir("//home//itachi//Music")
cnt_song = 0
for item in list_songs:
print(cnt_song,"-", item)
cnt_song += 1
to_pl=int(input("song number: "))
while to_pl >= 0 and to_pl <= cnt_song:
play_this(list_songs[to_pl])
cnt_song=0
else:
print("out of range")
# play_this()