Closed marcus-universe closed 10 months ago
Are you using v4 (legacy) or v5 sockets? If you are using v4, you need to pass legacy=True
to a call to obsws(...)
. For v5, you need to use different documentation (https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests) and use something like this:
tmp = ws.call(obsws_requests.GetSceneItemId(sceneName="Scene", sourceName="Game Capture"))
id = tmp.getSceneItemId()
res = ws.call(obsws_requests.GetSceneItemEnabled(sceneName="Scene", sceneItemId=id))
res.getSceneItemEnabled()
Are you using v4 (legacy) or v5 sockets? If you are using v4, you need to pass
legacy=True
to a call toobsws(...)
. For v5, you need to use different documentation (https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests) and use something like this:tmp = ws.call(obsws_requests.GetSceneItemId(sceneName="Scene", sourceName="Game Capture")) id = tmp.getSceneItemId() res = ws.call(obsws_requests.GetSceneItemEnabled(sceneName="Scene", sceneItemId=id)) res.getSceneItemEnabled()
I found a solution that worked for me but its not so elegant 😅 I using v5 😎 But thanks for the tip with the v5 docs. I was wondering why I getting different responses then in the docs 😄
import re
prevDroneState = ws.call(obs_requests.GetSourceActive(sourceName='Drohne'))
state_str = str(prevDroneState)
videoActive = re.search("'videoActive': (\w+)", state_str)
videoShowing = re.search("'videoShowing': (\w+)", state_str)
if videoActive:
print("Video Active: {}".format(videoActive.group(1)))
if videoShowing:
print("Video Showing: {}".format(videoShowing.group(1)))
Are you using v4 (legacy) or v5 sockets? If you are using v4, you need to pass
legacy=True
to a call toobsws(...)
. For v5, you need to use different documentation (https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requests) and use something like this:tmp = ws.call(obsws_requests.GetSceneItemId(sceneName="Scene", sourceName="Game Capture")) id = tmp.getSceneItemId() res = ws.call(obsws_requests.GetSceneItemEnabled(sceneName="Scene", sceneItemId=id)) res.getSceneItemEnabled()
You solution worked. Thanks alot again 👍
I read out my Drohne Source in OBS if its active or not active.
I looked into https://github.com/obsproject/obs-websocket/blob/4.x-compat/docs/generated/protocol.md#getsourceactive and seen that I need to get the sourceActive response/object.
I tried to use dot notations like:
But it dosent work and just result in errors like:
How I can get only the videoActive or videoShowing result?
This is my Print result:
Drone is <GetSourceActive request ({'sourceName': 'Drohne'}) called: success ({'videoActive': False, 'videoShowing': False})>