From 36e985fbcb52cec300552502147db5512791d9af Mon Sep 17 00:00:00 2001 From: Naoto Kondo Date: Fri, 18 Mar 2022 15:09:55 +0900 Subject: [PATCH] add example for find sources --- example/find.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 example/find.py diff --git a/example/find.py b/example/find.py new file mode 100644 index 0000000..1c23352 --- /dev/null +++ b/example/find.py @@ -0,0 +1,32 @@ +import sys +import time +import NDIlib as ndi + +def main(): + + if not ndi.initialize(): + return 0 + + ndi_find = ndi.find_create_v2() + + if ndi_find is None: + return 0 + + t = time.time() + while time.time() - t < 1.0: + if not ndi.find_wait_for_sources(ndi_find, 5000): + print('No change to the sources found.') + continue + sources = ndi.find_get_current_sources(ndi_find) + print('Network sources (%s found).' % len(sources)) + for i, s in enumerate(sources): + print('%s. %s' % (i + 1, s.ndi_name)) + + ndi.find_destroy(ndi_find) + + ndi.destroy() + + return 0 + +if __name__ == "__main__": + sys.exit(main())