-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicPlayer.py
More file actions
32 lines (28 loc) · 798 Bytes
/
MusicPlayer.py
File metadata and controls
32 lines (28 loc) · 798 Bytes
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
#!/data/data/com.termux/files/usr/bin/python
from time import sleep
from random import shuffle
from os import listdir,popen
Music = listdir('/sdcard/Music/rewind/netease/')
shuffle(Music)
def get_status():
info = []
status = popen('termux-media-player info').read()
if status == 'No track currently!\n':
info.append(False)
else:
info.append(True)
info.append(status[-14:-1])
return info
def play(path):
popen(f'termux-media-player play "/sdcard/Music/rewind/netease/{path}"')
try:
for i in Music:
play(i)
status = get_status()
while status[0]:
print(i,status[1].replace('.mp3',''),end='\r')
sleep(0.9)
status = get_status()
except:
popen('termux-media-player stop')
print()