From 1566fbac90bb40e5949d2fb91c15def697159eb4 Mon Sep 17 00:00:00 2001 From: ZurMaD Date: Tue, 15 Jun 2021 23:27:39 -0500 Subject: [PATCH] JSON inside python3 --- pipewire_python/__init__.py | 2 +- pipewire_python/pipewireAPICommands.json | 9 --------- pipewire_python/pipewirecontroller.py | 11 +++++++++-- tutorial.py | 5 +++++ 4 files changed, 15 insertions(+), 12 deletions(-) delete mode 100644 pipewire_python/pipewireAPICommands.json create mode 100644 tutorial.py diff --git a/pipewire_python/__init__.py b/pipewire_python/__init__.py index a303e53..6f53753 100644 --- a/pipewire_python/__init__.py +++ b/pipewire_python/__init__.py @@ -1,7 +1,7 @@ """pipewire_python: Python controller, player and recorder via pipewire's commands""" -__version__ = "0.0.4" +__version__ = "0.0.5" import sys diff --git a/pipewire_python/pipewireAPICommands.json b/pipewire_python/pipewireAPICommands.json deleted file mode 100644 index f08bd5f..0000000 --- a/pipewire_python/pipewireAPICommands.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "play": ["pw-play","COMMAND_HERE"], - "record": ["pw-record"], - "cat":"pw-cat", - "mon":"pw-mon", - "dot":"pw-dot", - "top":"pw-top", - "dump":"pw-dump" -} \ No newline at end of file diff --git a/pipewire_python/pipewirecontroller.py b/pipewire_python/pipewirecontroller.py index 8cc8335..a729997 100644 --- a/pipewire_python/pipewirecontroller.py +++ b/pipewire_python/pipewirecontroller.py @@ -2,6 +2,14 @@ import json KEY_TO_REPLACE = "COMMAND_HERE" +PIPEWIRE_API_COMMANDS = {"play": ["pw-play", "COMMAND_HERE"], + "record": ["pw-record"], + "cat": "pw-cat", + "mon": "pw-mon", + "dot": "pw-dot", + "top": "pw-top", + "dump": "pw-dump" + } class Player: @@ -10,8 +18,7 @@ class Player: def __init__(self): - with open("pipewire_python/pipewireAPICommands.json", "r") as json_file: - self.commands_json = json.load(json_file) + self.commands_json =PIPEWIRE_API_COMMANDS def play_WAV_File(self, audio_path): """ diff --git a/tutorial.py b/tutorial.py new file mode 100644 index 0000000..6d24b89 --- /dev/null +++ b/tutorial.py @@ -0,0 +1,5 @@ +from pipewire_python.pipewirecontroller import Player + + +player=Player() +player.play_WAV_File('../docs/beers.wav') \ No newline at end of file