2022-07-27 19:39:33 +01:00
|
|
|
import inspect
|
|
|
|
|
|
|
|
import keyboard
|
|
|
|
import obsstudio_sdk as obs
|
|
|
|
|
|
|
|
|
|
|
|
class Observer:
|
|
|
|
def __init__(self, cl):
|
|
|
|
self._cl = cl
|
|
|
|
self._cl.callback.register(self.on_current_program_scene_changed)
|
|
|
|
print(f"Registered events: {self._cl.callback.get()}")
|
|
|
|
|
|
|
|
@property
|
|
|
|
def event_identifier(self):
|
|
|
|
return inspect.stack()[1].function
|
|
|
|
|
|
|
|
def on_current_program_scene_changed(self, data):
|
|
|
|
"""The current program scene has changed."""
|
2022-07-27 22:44:40 +01:00
|
|
|
print(f"{self.event_identifier}: {data.scene_name}")
|
2022-07-27 19:39:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
def version():
|
|
|
|
print(req_cl.get_version())
|
|
|
|
|
|
|
|
|
|
|
|
def set_scene(scene, *args):
|
|
|
|
req_cl.set_current_program_scene(scene)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
req_cl = obs.ReqClient()
|
2022-07-27 19:43:34 +01:00
|
|
|
ev_cl = obs.EventClient()
|
|
|
|
observer = Observer(ev_cl)
|
2022-07-27 19:39:33 +01:00
|
|
|
|
|
|
|
keyboard.add_hotkey("1", set_scene, args=("START",))
|
|
|
|
keyboard.add_hotkey("2", set_scene, args=("BRB",))
|
|
|
|
keyboard.add_hotkey("3", set_scene, args=("END",))
|
|
|
|
|
|
|
|
print("press ctrl+enter to quit")
|
|
|
|
keyboard.wait("ctrl+enter")
|