Пример #1
0
def TransitionToProgram(Action, ws):
    #Here we check whether StudioMode is on
    StudioState = CheckStudioState(ws)
    #Here we make the transition
    if StudioState == True:
        #Here we set the configured transition mode
        if "Transition" in Action:
            Transition_old = GetTransition(ws)
            SetTransition(Action, ws)
        #Here we make the transition
        try:
            CurrentsceneObject = ws.call(requests.GetPreviewScene())
            Currentscene = CurrentsceneObject.getName()
            ws.call(requests.SetCurrentScene(Currentscene))
        except:
            print("Couldn't send preview to program")
        else:
            PrintWithTime("Sent preview to program")
        #Here we set the transition mode back
        if "Transition" in Action:
            try:
                Duration = ws.call(requests.GetTransitionDuration())
                Duration = Duration.getTransitionDuration()
            except:
                print("Couldn't get transition duration")
            else:
                time.sleep(Duration / 1000 + 0.1)
            finally:
                SetTransition(Transition_old, ws)
    else:
        print("StudioMode not enabled")
Пример #2
0
 def GetPreviewScene(self):
     try:
         data = self.ws.call(requests.GetPreviewScene()).__dict__["datain"]
         if "error" in data:
             return None
         else:
             return data
     except Exception as e:
         print(e)
Пример #3
0
def TransitionToProgram():
	#Here we check whether StudioMode is on
	StudioState = CheckStudioState()
	#Here we make the transition
	if StudioState == True:
		try:
			CurrentsceneObject = ws.call(requests.GetPreviewScene())
			Currentscene = CurrentsceneObject.getName()
			ws.call(requests.SetCurrentScene(Currentscene))
			print("Sent preview to program")
		except:
			print("Couldn't send preview to program")
	else:
		print("StudioMode not enabled")
Пример #4
0
    def change_scene(self, amount):
        """
        Jump to the next / previous scene.

        The web socket will only give us the current scene name and an orderd list of scenes;
        we therefore need to work out the index of the current scene and then the name of the
        desired scene to jump to.
        """
        if self.connection.call(
                requests.GetStudioModeStatus()).getStudioMode() == False:
            print('Studio mode must be on for scene switching')
            return

        scenes = self.connection.call(requests.GetSceneList()).getScenes()
        current_scene = self.connection.call(
            requests.GetPreviewScene()).getName()
        current_scene_index = [
            i for i, s in enumerate(scenes) if s['name'] == current_scene
        ][0]
        new_scene_index = (current_scene_index + amount) % len(scenes)
        new_scene = scenes[new_scene_index]['name']
        self.connection.call(requests.SetPreviewScene(new_scene))
Пример #5
0
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")
            ipAddressHistory = open(
                "obsAddr.log",
                "w")  #Store the connected IP address in the log file
            ipAddressHistory.write(addr)
            ipAddressHistory.close()
            if usn.find(
                    cam_num_str
            ) > -1:  #Set initial Program LED states  (since changes are based on events) - No way to determine current Preview scene?
                #                      GPIO.output(GPIO_tally_prev, 1)
                #                      if debug_level >= 1: print("   Preview LED ON")
                #                      LED_prev_state = 1
                GPIO.output(GPIO_tally_prog, 1)
                if debug_level >= 1: print("   Program LED ON")
                LED_prog_state = 1
            message = ws.call(
                requests.GetPreviewScene()
            )  #Get the Name of the Scene currently in Preview (chk connection and set initial Prog LED state)
            sn = str(message)[str(message).find("name"):]
            sn = sn[:sn.find(",")]
            usn = sn.upper()
            if usn.find(
                    cam_num_str
            ) > -1:  #Set initial Program LED states  (since changes are based on events) - No way to determine current Preview scene?
                GPIO.output(GPIO_tally_prev, 1)
                if debug_level >= 1: print("   Preview LED ON")
                LED_prev_state = 1

        while connected:  #Flash the Connected LED, 20ms on, 980ms off to indicate connected state=TRUE
            GPIO.output(GPIO_connected, GPIO.LOW)
            time.sleep(0.98)
            GPIO.output(GPIO_connected, GPIO.HIGH)