aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pipfile1
-rw-r--r--Pipfile.lock9
-rwxr-xr-xquiz.py19
3 files changed, 12 insertions, 17 deletions
diff --git a/Pipfile b/Pipfile
index 657df43..5ad471a 100644
--- a/Pipfile
+++ b/Pipfile
@@ -6,6 +6,7 @@ name = "pypi"
[packages]
pysimplegui = "*"
psutil = "*"
+playsound = "*"
[dev-packages]
yapf = "*"
diff --git a/Pipfile.lock b/Pipfile.lock
index fea8966..bfdc635 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "6eee3e0bc56cbe8b817160150d65f011413ee574ec91664d2c5b52a1668d7016"
+ "sha256": "650e3ae04b710f3e337e2ee034cf586ba8d53629bcb446983191592de5ef1fc6"
},
"pipfile-spec": 6,
"requires": {
@@ -16,6 +16,13 @@
]
},
"default": {
+ "playsound": {
+ "hashes": [
+ "sha256:cc6ed11d773034b0ef624e6bb4bf50f4b76b8414a59ce6d38afb89b423297ced"
+ ],
+ "index": "pypi",
+ "version": "==1.3.0"
+ },
"psutil": {
"hashes": [
"sha256:104a5cc0e31baa2bcf67900be36acde157756b9c44017b86b2c049f11957887d",
diff --git a/quiz.py b/quiz.py
index a9248e3..f3b3c3e 100755
--- a/quiz.py
+++ b/quiz.py
@@ -24,15 +24,11 @@ import sys
import PySimpleGUI as sg
import psutil
+import playsound
WRONG_SOUND = Path(__file__).parent / 'Wrong.mp3'
CORRECT_SOUND = Path(__file__).parent / 'Correct.mp3'
-if platform.system() != 'Windows':
- PLAY_SOUND_CMD = 'mpv'
-else:
- PLAY_SOUND_CMD = 'vlc.exe --intf=dummy --dummy-quiet'
-
SHOW_QUESTION_CMD = 'xdg-open'
@@ -42,15 +38,6 @@ def err(msg: str, status=1):
sys.exit(status)
-def play_sound(sound: Path):
- """Play a sound file"""
- cmd = PLAY_SOUND_CMD.split() + [str(sound)]
- subprocess.run(cmd,
- check=True,
- stderr=subprocess.DEVNULL,
- stdout=subprocess.DEVNULL)
-
-
def terminate_subprocesses():
"""Terminate all started subprocesses"""
procs = psutil.Process().children(recursive=True)
@@ -186,10 +173,10 @@ def prompt_solution(solution: str, prompts=None):
break
color_button(layout[0], event, '#FF0000')
- play_sound(WRONG_SOUND)
+ playsound.playsound(WRONG_SOUND)
color_button(layout[0], event, '#00FF00')
- play_sound(CORRECT_SOUND)
+ playsound.playsound(CORRECT_SOUND)
window.read()
window.close()