2022-07-25 23:51:30 +01:00
|
|
|
import obsstudio_sdk as obs
|
|
|
|
|
|
|
|
|
|
|
|
class Observer:
|
|
|
|
def __init__(self, cl):
|
|
|
|
self._cl = cl
|
|
|
|
self._cl.callback.register(
|
2022-07-26 04:36:55 +01:00
|
|
|
[
|
|
|
|
self.on_current_program_scene_changed,
|
|
|
|
self.on_scene_created,
|
|
|
|
self.on_input_mute_state_changed,
|
|
|
|
self.on_exit_started,
|
|
|
|
]
|
2022-07-25 23:51:30 +01:00
|
|
|
)
|
|
|
|
print(f"Registered events: {self._cl.callback.get()}")
|
|
|
|
|
2022-07-26 04:36:55 +01:00
|
|
|
def on_current_program_scene_changed(self, data):
|
|
|
|
print(f"Switched to scene {data['sceneName']}")
|
|
|
|
|
|
|
|
def on_scene_created(self, event, data):
|
|
|
|
"""A new scene has been created."""
|
|
|
|
print(f"{event}: {data}")
|
|
|
|
|
|
|
|
def on_input_mute_state_changed(self, event, data):
|
|
|
|
"""An input's mute state has changed."""
|
|
|
|
print(f"{event}: {data}")
|
|
|
|
|
2022-07-25 23:51:30 +01:00
|
|
|
def on_exit_started(self):
|
|
|
|
print(f"OBS closing!")
|
|
|
|
self._cl.unsubscribe()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
cl = obs.EventsClient()
|
|
|
|
observer = Observer(cl)
|
|
|
|
|
|
|
|
while cmd := input("<Enter> to exit\n"):
|
|
|
|
if not cmd:
|
|
|
|
break
|