mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2025-04-19 03:33:54 +01:00
Compare commits
No commits in common. "b5b5633577452e91c419f800e4635646af5d15f3" and "fd4a2280861fcf4d4b0c9ff80f6b86aa82812fba" have entirely different histories.
b5b5633577
...
fd4a228086
@ -1,6 +1,5 @@
|
|||||||
[](https://badge.fury.io/py/xair-api)
|
[](https://badge.fury.io/py/xair-api)
|
||||||
[](https://github.com/onyx-and-iris/xair-api-python/blob/dev/LICENSE)
|
[](https://github.com/onyx-and-iris/xair-api-python/blob/dev/LICENSE)
|
||||||
[](https://python-poetry.org/)
|
|
||||||
[](https://github.com/astral-sh/ruff)
|
[](https://github.com/astral-sh/ruff)
|
||||||

|

|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ password = "mystrongpass"
|
|||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
Change the xair ip argument from `mixer.local` to the ip of your xair mixer. Run the code and switch between scenes in OBS. Closing OBS will end the script.
|
Change the xair ip argument from `mixer.local` to the ip of your xair mixer. Run the code and switch between scenes in OBS.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
@ -1,48 +1,13 @@
|
|||||||
import threading
|
import obsws_python as obs
|
||||||
from logging import config
|
|
||||||
|
|
||||||
import obsws_python as obsws
|
|
||||||
|
|
||||||
import xair_api
|
import xair_api
|
||||||
|
|
||||||
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': {
|
|
||||||
'xair_api.xair': {
|
|
||||||
'handlers': ['stream'],
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'propagate': False,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'root': {'handlers': ['stream'], 'level': 'WARNING'},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Observer:
|
class Observer:
|
||||||
def __init__(self, mixer, stop_event):
|
def __init__(self, mixer):
|
||||||
self._mixer = mixer
|
self._mixer = mixer
|
||||||
self._stop_event = stop_event
|
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,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
@ -67,16 +32,12 @@ class Observer:
|
|||||||
self._mixer.config.mute_group[0].on = True
|
self._mixer.config.mute_group[0].on = True
|
||||||
print(f'Mute Group 1 is {self._mixer.config.mute_group[0].on}')
|
print(f'Mute Group 1 is {self._mixer.config.mute_group[0].on}')
|
||||||
|
|
||||||
def on_exit_started(self, _):
|
|
||||||
self._stop_event.set()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with xair_api.connect('MR18', ip='mixer.local') as mixer:
|
with xair_api.connect('MR18', ip='mixer.local') as mixer:
|
||||||
stop_event = threading.Event()
|
with Observer(mixer):
|
||||||
|
while _ := input('Press <Enter> to exit\n'):
|
||||||
with Observer(mixer, stop_event):
|
pass
|
||||||
stop_event.wait()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user