def __init__(self, stream_name: str = None) -> None: super().__init__() # The YouTube title name will have to be updated before running # audiosync. self.youtube_title = None self._is_running = False # Tries to initialize the dedicated PulseAudio sink at the beginning. if stream_name is not None: audiosync.setup(stream_name)
#!/usr/bin/env python3 # Very simple test to make sure that the Python bindings work correctly. # This will simply call the functions and do a basic test to make sure # they import threading import audiosync print(">> Calling setup function") audiosync.setup("test") # The provided arguments won't actually work inside audiosync, but it's # enough to check if any Python errors are raised. print(">> Starting main thread") th1 = threading.Thread(target=audiosync.run, args=("", )) th1.start() print(">> Pausing thread") audiosync.pause() status = audiosync.status() print(">> Current status is", status) assert (status == 'paused') print(">> Resuming thread") audiosync.resume() status = audiosync.status() print(">> Current status is", status) assert (status == 'running')
#!/usr/bin/env python3 import sys import audiosync # Checking that the script was used correctly if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} \"SONG_NAME\" [SINK_NAME]\n" "After running the script, start the song in the background.") exit(1) # After this is printed, the music should start playing in the background too # Running the audiosync setup in case the sink name was provided if len(sys.argv) == 3: print(f"Setting up audiosync with sinkname {sys.argv[1]}") audiosync.setup() # And finally the actual algorithm is ran print("Running audiosync") ret, success = audiosync.run(sys.argv[1]) print(f"Obtained lag (success={success}): {ret}")