Skip to content

Commit deabb10

Browse files
committed
✅ add test_players.py
1 parent daa2e83 commit deabb10

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

test_players.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import time
2+
from src.badapple.players import get_player
3+
from src.badapple.builtin_files import BA_BA, BA_MP4,BA_MP3, BA_WAV, ba_get
4+
5+
6+
def test(p: str, a: str) -> None:
7+
a = ba_get(a)
8+
print(p, a)
9+
player = get_player(p, a)
10+
print('is_available', player.is_available())
11+
if not player.is_available():
12+
return
13+
player.start()
14+
print('started')
15+
print('is_alive', player.is_alive())
16+
try:
17+
for i in range(6):
18+
time.sleep(0.5)
19+
print(i+1, 'is_alive', player.is_alive())
20+
except KeyboardInterrupt:
21+
pass
22+
finally:
23+
print('before is_alive', player.is_alive())
24+
player.terminate()
25+
print('after is_alive', player.is_alive())
26+
print('end')
27+
28+
29+
__FFPLAY = 'ffplay' # all
30+
__AVPLAY = 'avplay' # all
31+
__MPV = 'mpv'
32+
__VLC = 'vlc'
33+
__MPG123 = 'mpg123' # mp3
34+
__CMUS = 'cmus'
35+
__SIMPLEAUDIO = 'simpleaudio' # wav
36+
__PYAUDIO = 'pyaudio' # wav
37+
__PLAYSOUND = 'playsound' # mp3+wav not_win
38+
__PYDUB = 'pydub' # simpleaudio-pyaudio-avplay-ffplay
39+
40+
__AUTO = 'auto'
41+
42+
test(__AUTO, BA_WAV)

0 commit comments

Comments
 (0)