def CheckStudioState(): StudioState = False try: StudioState = ws.call(requests.GetStudioModeStatus()) StudioState = StudioState.getStudioMode() except: print("Couldn't get StudioModeStatus") return StudioState
def switch_to(self, scene: str): res = self.ws.call(obsws_requests.GetStudioModeStatus()) if not res.getStudioMode(): self.ws.call(obsws_requests.EnableStudioMode()) self.ws.call(obsws_requests.SetPreviewScene(scene)) self.ws.call(obsws_requests.TransitionToProgram('Stinger')) self.ws.call(obsws_requests.DisableStudioMode())
def Scene_Set_Safe(self, SceneName="", *args, **kwargs): try: r = self.ws.call(requests.GetStudioModeStatus()) r = r.__dict__["datain"] if r["studio-mode"]: self.StudioMode_SetPreview(SceneName = SceneName, *args, **kwargs) else: self.Scene_Set(SceneName = SceneName, *args, **kwargs) except Exception as e: PrintWithTime(f"Couldn't get studio mode status. Error : {e}")
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))
def GetStudioModeStatus(self): try: return self.ws.call(requests.GetStudioModeStatus() ).__dict__["datain"]["studio-mode"] except Exception as e: print(e)
def init(self): self.studio_mode = self.ws.call( requests.GetStudioModeStatus()).getStudioMode() self.init_scenes() # self.init_volume() self.vol_timer = RepeatedTimer(1, self.init_volume)