-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_src.py
74 lines (67 loc) · 1.84 KB
/
test_src.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
import time
import multiprocessing
from badapple.builtin_files import BA_MP4, BA_MP3, BA_WAV, ba_get
from src.anyplayer import get_player, VERSION, get_names, get_availables
def test(p: str, a: str) -> None:
a = ba_get(a)
# print(a)
player = get_player(p, a)
print(player)
print('is_available', player.is_available())
if not player.is_available():
return
player.start()
print('started')
print('is_alive', player.is_alive())
try:
for i in range(6):
time.sleep(0.5)
print(i+1, 'is_alive', player.is_alive())
except KeyboardInterrupt:
pass
finally:
print('before is_alive', player.is_alive())
player.terminate()
if player.is_alive():
print(0.5)
time.sleep(0.5)
print('after is_alive', player.is_alive())
print('end')
print()
FFPLAY = 'ffplay'
MPV = 'mpv'
VLC = 'vlc'
MPG123 = 'mpg123' # mp3
CMUS = 'cmus' # mp3 mp4
APLAY = 'aplay'
GST = 'gst'
SIMPLEAUDIO = 'simpleaudio' # wav
PYAUDIO = 'pyaudio' # mp3+wav
PLAYSOUND = 'playsound' # mp3+wav
FILEMGR = 'filemgr'
ELISA = 'elisa'
AUTO = 'auto'
if __name__ == '__main__':
multiprocessing.freeze_support()
print(VERSION)
ss = get_names()
print('get_names', ss)
print('get_availables', get_availables())
print()
for i in ss:
time.sleep(1)
if i in [MPG123, CMUS]:
test(i, BA_MP3)
elif i in [SIMPLEAUDIO, APLAY]:
test(i, BA_WAV)
elif i in [PLAYSOUND, PYAUDIO]:
test(i, BA_MP3)
test(i, BA_MP3)
test(i, BA_WAV)
test(i, BA_WAV)
else:
test(i, BA_MP4)
test(i, BA_MP3)
test(i, BA_WAV)
print('[%s] tested' % i)
print()