Docs - Examples - events
This example is a simple demo of the events in the library:
$ python3 events.py -h
[Mon Dec 7 03:38:41 2020] PyATEMMax demo script: events
usage: events.py [-h] [-i INTERVAL] ip
positional arguments:
ip switcher IP address
optional arguments:
-h, --help show this help message and exit
-i INTERVAL, --interval INTERVAL
wait INTERVAL seconds between changes, default: 1.0
It tries to connect to the specified ip and once a second it changes PGM
/PVW
to random values between 1 and 8 every INTERVAL
seconds, while showing information about received data.
$ python3 events.py 192.168.1.111
[Mon Dec 7 03:37:30 2020] PyATEMMax demo script: events
[Mon Dec 7 03:37:30 2020] Changing PGM/PVW on ATEM switcher at 192.168.1.111 every 1.0 seconds
[Mon Dec 7 03:37:30 2020] Waiting for connection
[Mon Dec 7 03:37:30 2020] Trying to connect to switcher at 192.168.1.111
[Mon Dec 7 03:37:31 2020] Connected to switcher at 192.168.1.111
[Mon Dec 7 03:37:31 2020] Changing PGM
[Mon Dec 7 03:37:31 2020] Changing PVW
[Mon Dec 7 03:37:31 2020] Received [Time]: Last State Change Time Code
[Mon Dec 7 03:37:31 2020] Received [TlIn]: Tally By Index
[Mon Dec 7 03:37:31 2020] Received [TlSr]: Tally By Source
[Mon Dec 7 03:37:31 2020] Received [PrgI]: Program Input
[Mon Dec 7 03:37:31 2020] Received [PrvI]: Preview Input
[Mon Dec 7 03:37:32 2020] Received [Time]: Last State Change Time Code
[Mon Dec 7 03:37:32 2020] Changing PGM
[Mon Dec 7 03:37:32 2020] Changing PVW
[Mon Dec 7 03:37:32 2020] Received [Time]: Last State Change Time Code
[Mon Dec 7 03:37:32 2020] Received [TlIn]: Tally By Index
[Mon Dec 7 03:37:32 2020] Received [TlSr]: Tally By Source
[Mon Dec 7 03:37:32 2020] Received [PrvI]: Preview Input
[Mon Dec 7 03:37:33 2020] Changing PGM
[Mon Dec 7 03:37:33 2020] Changing PVW
[Mon Dec 7 03:37:33 2020] Received [Time]: Last State Change Time Code
[Mon Dec 7 03:37:33 2020] Received [TlIn]: Tally By Index
[Mon Dec 7 03:37:33 2020] Received [TlSr]: Tally By Source
[Mon Dec 7 03:37:33 2020] Received [PrgI]: Program Input
[Mon Dec 7 03:37:33 2020] Received [PrvI]: Preview Input
...
Code walkthrough
Start with the usual initial steps (explained in Examples)
At this point, the event handlers are defined.
All events receive a params
dictionary, which in all cases will contain a switcher
item containing a reference to the switcher object generating the event (to allow using a single event handler for multiple ATEMMax
instances).
Some events include extra information.
Start working with the switcher:
First, the ATEMMax
object is created:
After creating the switcher object, event handlers are registered:
Then, the script connects to the switcher and enters an infinite loop changing PGM
and PVW
if the switcher is connected:
This allows for an easy fit of the library in GUI apps. Just register your event handlers and forget about the switcher :)