mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
example now registeres on_exit_started
script will now end when OBS is closed filter out all logs but `vban_cmd.iremote` setup.py added
This commit is contained in:
parent
7a3abfc372
commit
ca9a31c94a
@ -40,10 +40,12 @@ Make sure you have established a working connection to OBS and the remote Voicem
|
|||||||
|
|
||||||
Run the script, change OBS scenes and watch Voicemeeter parameters change.
|
Run the script, change OBS scenes and watch Voicemeeter parameters change.
|
||||||
|
|
||||||
Pressing `<Enter>` will exit.
|
Closing OBS will end the script.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
All but `vban_cmd.iremote` logs are filtered out. Log in DEBUG mode.
|
||||||
|
|
||||||
This script can be run from a Linux host since the vban-cmd interface relies on UDP packets and obsws-python runs over websockets.
|
This script can be run from a Linux host since the vban-cmd interface relies on UDP packets and obsws-python runs over websockets.
|
||||||
|
|
||||||
You could for example, set this up to run in the background on a home server such as a Raspberry Pi.
|
You could for example, set this up to run in the background on a home server such as a Raspberry Pi.
|
||||||
|
@ -1,16 +1,41 @@
|
|||||||
import logging
|
import time
|
||||||
|
from logging import config
|
||||||
|
|
||||||
|
import obsws_python as obsws
|
||||||
|
|
||||||
import obsws_python as obs
|
|
||||||
import vban_cmd
|
import vban_cmd
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
config.dictConfig(
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"formatters": {
|
||||||
|
"standard": {
|
||||||
|
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"handlers": {
|
||||||
|
"stream": {
|
||||||
|
"level": "DEBUG",
|
||||||
|
"class": "logging.StreamHandler",
|
||||||
|
"formatter": "standard",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loggers": {"vban_cmd.iremote": {"handlers": ["stream"], "level": "DEBUG"}},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Observer:
|
class Observer:
|
||||||
def __init__(self, vban):
|
def __init__(self, vban):
|
||||||
self.vban = vban
|
self.vban = vban
|
||||||
self.client = obs.EventClient()
|
self.client = obsws.EventClient()
|
||||||
self.client.callback.register(self.on_current_program_scene_changed)
|
self.client.callback.register(
|
||||||
|
(
|
||||||
|
self.on_current_program_scene_changed,
|
||||||
|
self.on_exit_started,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.is_running = True
|
||||||
|
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
self.vban.strip[0].mute = True
|
self.vban.strip[0].mute = True
|
||||||
@ -50,13 +75,16 @@ class Observer:
|
|||||||
if fn := fget(scene):
|
if fn := fget(scene):
|
||||||
fn()
|
fn()
|
||||||
|
|
||||||
|
def on_exit_started(self, _):
|
||||||
|
self.client.unsubscribe()
|
||||||
|
self.is_running = False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with vban_cmd.api("potato", sync=True) as vban:
|
with vban_cmd.api("potato") as vban:
|
||||||
obs = Observer(vban)
|
observer = Observer(vban)
|
||||||
while cmd := input("<Enter> to exit\n"):
|
while observer.is_running:
|
||||||
if not cmd:
|
time.sleep(0.1)
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
7
examples/obs/setup.py
Normal file
7
examples/obs/setup.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="obs",
|
||||||
|
description="OBS Example",
|
||||||
|
install_requires=["obsws-python"],
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user