diff --git a/examples/obs/README.md b/examples/obs/README.md new file mode 100644 index 0000000..a84c366 --- /dev/null +++ b/examples/obs/README.md @@ -0,0 +1,19 @@ +## Requirements + +- [OBS Studio](https://obsproject.com/) +- [OBS Websocket Plugin](https://obsproject.com/forum/resources/obs-websocket-remote-control-obs-studio-from-websockets.466/) +- [OBS Websocket Py](https://github.com/onyx-and-iris/obs-websocket-py) + +## About + +A simple demonstration showing how to sync OBS scene switches to Voicemeeter states. The script assumes you have connection info saved in +a config file named `config.ini` placed next to `__main__.py`. It also assumes you have scenes named `START` `BRB` `END` and `LIVE`. + +A valid `config.ini` file might look like this: + +```ini +[connection] +ip=localhost +port=4444 +password=mystrongpassword +``` diff --git a/examples/obs/__main__.py b/examples/obs/__main__.py new file mode 100644 index 0000000..83e4c55 --- /dev/null +++ b/examples/obs/__main__.py @@ -0,0 +1,50 @@ +import logging +import sys + +import voicemeeterlib + +logging.basicConfig(level=logging.INFO) + +sys.path.append("../") +from obswebsocket import events, obsws + + +def on_start(): + vm.strip[0].mute = True + + +def on_brb(): + vm.strip[7].fadeto(0, 500) + + +def on_end(): + vm.strip[0].mute = True + + +def on_live(): + vm.strip[0].mute = False + vm.strip[7].fadeto(-6, 500) + + +def on_switch(message): + scene = message.getSceneName() + match scene: + case "START": + on_start() + case "BRB": + on_brb() + case "END": + on_end() + case "LIVE": + on_live() + case _: + pass + + +with voicemeeterlib.api("potato") as vm: + with obsws() as ws: + ws.register(on_switch, events.SwitchScenes) + + while cmd := input("Press to exit\n"): + if not cmd: + break