def transition_switch(unused_addr, args, oscValue, timeValue=-1): try: if (is_integer(oscValue)): transition_name = TransitionNames[int(oscValue)] else: transition_name = oscValue if (is_integer(timeValue) and int(timeValue) >= 0): print("{0} '{1}' {2}".format(args[0], transition_name, timeValue)) ws.call(requests.SetTransitionDuration(int(timeValue))) ws.call(requests.SetCurrentTransition(transition_name)) else: print("{0} '{1}'".format(args[0], transition_name)) ws.call(requests.SetCurrentTransition(transition_name)) except: pass
def SetTransition(Action, ws): if "Transition" in Action: try: ws.call(requests.SetCurrentTransition(Action["Transition"])) except: print("Couldn't set transition: " + Action["Transition"]) else: PrintWithTime("TransitionMode was changed to " + Action["Transition"]) else: print("No transition set up in action config") if "TransitionDuration" in Action: SetTransitionDuration(Action, None, ws)
def SetTransitionMode(Transition, Duration): #This variable is used to check whether an error occured Error = False #Here we set the transition type if Transition != None: try: ws.call(requests.SetCurrentTransition(Transition)) print("TransitionMode was changed to " + Transition) except: print("Couldn't set transition: " + Transition) Error = True #Here we set the transition duration if Duration != None: try: ws.call(requests.SetTransitionDuration(Duration)) print("TransitionDuration was changed to " + str(Duration) + "ms") except: print("Couldn't set transition duration: " + str(Duration) + "ms") Error = True #Here we return whether or not an error occured return Error
def press_button(Button): if Button == 8: try: print("Connecting to Camera1") ws.call(requests.SetPreviewScene("Camera1")) except: print("Exception happened") elif Button == 9: try: print("Connecting to Camera2") ws.call(requests.SetPreviewScene("Camera2")) except: print("Exception happened") elif Button == 15: try: print("Send to stream") CurrentsceneObject = ws.call(requests.GetPreviewScene()) # print(CurrentsceneObject) Currentscene = CurrentsceneObject.getName() # print(Currentscene) ws.call(requests.SetCurrentTransition("Fade")) ws.call(requests.SetCurrentScene(Currentscene)) except: print("Exception happened")
def SetCurrentTransition(self, TransitionName): try: self.ws.call(requests.SetCurrentTransition(TransitionName)) except Exception as e: print(e)
def Setup(): PrintWithTime("Program started") #First we read the config to correctly define our global variables global SETUP_JSON #This allows us to either put the config name in the argv variables or to get asked for the config #Example: python ProgramName.py ConfigName if len(sys.argv) > 1: Filename = sys.argv[1] else: Filename = input("What is the name of your config file? --> ") if Filename == "": Filename = "FrequenceBanane" #Open the config JSON try: SETUP_JSON = json.loads(''.join(open("Config\\" + Filename + ".json", "r"))) except FileNotFoundError: print("Config " + Filename + " not found") print("Exiting program") exit() except: print("Couldn't open " + Filename + ".json") print("Exiting program") exit() else: PrintWithTime("Opened config: " + Filename) #Define the global variables correctly if "config_general" in SETUP_JSON: config_general = SETUP_JSON["config_general"] if "ConfigName" in config_general: global ConfigName ConfigName = config_general["ConfigName"] else: print("ERROR 404: ConfigName argument was not found") if "StudioModeDefault" in config_general: global StudioModeDefault StudioModeDefault = config_general["StudioModeDefault"] else: print("ERROR 404: StudioModeDefault argument was not found") if "DefaultTransition" in config_general: global DefaultTransition DefaultTransition = config_general["DefaultTransition"] else: print("ERROR 404: DefaultTransition argument was not found") if "DefaultTransitionDuration" in config_general: global DefaultTransitionDuration DefaultTransitionDuration = config_general["DefaultTransitionDuration"] else: print("ERROR 404: DefaultTransitionDuration argument was not found") if "server_ip" in config_general: global server_ip server_ip = config_general["server_ip"] else: print("ERROR 404: server_ip argument was not found") if "server_port" in config_general: global server_port server_port = config_general["server_port"] else: print("ERROR 404: server_port argument as not found") if "server_password" in config_general: global server_password server_password = config_general["server_password"] else: print("ERROR 404 server_password argument was not found") if "SceneCollection" in config_general: global SceneCollection SceneCollection = config_general["SceneCollection"] else: print("ERROR 404 SceneCollection argument was not found") del config_general else: print("No general config in config file") if "config_pad" in SETUP_JSON: global config_pad config_pad = SETUP_JSON["config_pad"] del SETUP_JSON else: print("No pad config in config file") print("Exiting program") exit() #Here we connect to the OBS Websocket global ws try: ws = obsws(server_ip, server_port, server_password) ws.connect() except: print("Connection to OBS Websocket is impossible") print("Exiting program") exit() else: PrintWithTime("Connected to Websocket") #Here we connect to the midi pad global midi_in global midi_out try: midi.init() midi_in = midi.Input(1, 1024) midi_out = midi.Output(3, 1024) except: print("Midi Pad not found") print("Exiting program") exit() else: PrintWithTime("Connected Midi Pad") #Here we set up OBS like configured try: ws.call(requests.SetCurrentSceneCollection(SceneCollection)) except: print("Couldn't set scene collection: " + SceneCollection) else: PrintWithTime("Set scene collection: " + SceneCollection) #if StudioModeDefault == "True": # try: # ws.call(requests.EnableStudioMode()) # except: # print("Couldn't turn Studio Mode on") # else: # PrintWithTime("Studio Mode turned on") ---Causes Crash #else: # try: # ws.call(requests.DisableStudioMode()) # except: # print("Couldn't turn Studio Mode off") # else: # PrintWithTime("Studio Mode turned off") try: ws.call(requests.SetCurrentTransition(DefaultTransition)) except: print("Couldn't set transition: " + DefaultTransition) else: PrintWithTime("TransitionMode was changed to " + DefaultTransition) try: ws.call(requests.SetTransitionDuration(DefaultTransitionDuration)) except: print("Couldn't set transition duration: " + str(DefaultTransitionDuration) + "ms") else: PrintWithTime("TransitionDuration was changed to " + str(DefaultTransitionDuration) + "ms") PrintWithTime("Program is ready to use")
exit() else: if toggle == 1: #print "Script is ON, STOP NOW" exit() #Get the default Transition current_transition_name = ws.call( requests.GetCurrentTransition()).getName() if current_transition_name != "Cut": current_transition_duration = ws.call( requests.GetCurrentTransition()).getDuration() #If transition_override is true we change the transition style if transition_override is True and transition_random is False and transition_sequence is False: ws.call(requests.SetCurrentTransition(transition_list[0])) # Type if transition_list[0] != "Cut": ws.call( requests.SetTransitionDuration(transition_duration)) #Duration #First launch, write 1 on toggle file set_toggle(1) scenes_numbers = len(scenes_list) transition_numbers = len(transition_list) next_transition = 0 #print ("__STARTING SCRIPT, __REPEAT MODE :",repeat_mode,"__TOGGLE MODE :", toggle_mode) #print ("__Transition Override :", transition_override,"__Random", transition_random,"__Sequence", transition_sequence) #print ("__Scene List:", scenes_list) #print ("__Nombres de Scenes", scenes_numbers) #print ("__Transition List", transition_list)
def Transition_Set(self, TransitionName="", *args, **kwargs): try: self.ws.call(requests.SetCurrentTransition(TransitionName)) PrintWithTime(f"Set transition to {TransitionName}") except Exception as e: PrintWithTime(f"Couldn't set transition to {TransitionName}. Error : {e}")