Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpleobsws to perform the scene change #17

Open
chicco64 opened this issue Dec 21, 2022 · 3 comments
Open

Simpleobsws to perform the scene change #17

chicco64 opened this issue Dec 21, 2022 · 3 comments

Comments

@chicco64
Copy link

Hi !,
i would like to use your software to run a certain scene in obs;
these are the scenes currently loaded in my obs:

request = simpleobsws.Request( "GetSceneList" )

"scenes": [
{
"sceneIndex": 0,
"sceneName": "Scene 5"
},
{
"sceneIndex": 1,
"sceneName": "Scene 4"
},
{
"sceneIndex": 2,
"sceneName": "Scene 3"
},
{
"sceneIndex": 3,
"sceneName": "Scene 2"
},
{
"sceneIndex": 4,
"sceneName": "Scene"
}
]

I would like to use the "set Scene Name" (or another) function to execute, for example, "Scene 5", but I don't understand the syntax of the command itself.
Can you please give me a correct example to run, through your script "sample_request.py", the execution of a certain scene, among those present in obs studio
Many thanks !

@McMornan
Copy link

McMornan commented Jan 8, 2023

Hi, I second that. I have built a control hardware using a raspi, and want to change the scene on the touch of a button. For that I also need a hint in the right direction. The request eample does not show how to pass parameters. I want to know how I can set the reuqest parameter for 'SetCurrentProgramScene' request. Thanks

@McMornan
Copy link

McMornan commented Jan 8, 2023

Hi, I found it. Here is a python example code:

`import logging
logging.basicConfig(level=logging.DEBUG)
import asyncio
import simpleobsws

parameters = simpleobsws.IdentificationParameters(ignoreNonFatalRequestChecks = False) # Create an IdentificationParameters object (optional for connecting)

ws = simpleobsws.WebSocketClient(url = 'ws://192.168.2.130:4455', password = 'test123', identification_parameters = parameters) # Every possible argument has been passed, but none are required>

async def make_request():
await ws.connect() # Make the connection to obs-websocket
await ws.wait_until_identified() # Wait for the identification handshake to complete

data = {'sceneName': 'Beach2'} #, f'inputSettings: {url}': url}
request = simpleobsws.Request('SetCurrentProgramScene',data) # Build a Request object

ret = await ws.call(request) # Perform the request
if ret.ok(): # Check if the request succeeded
    print("Request succeeded! Response data: {}".format(ret.responseData))

await ws.disconnect() # Disconnect from the websocket server cleanly

loop = asyncio.get_event_loop()
loop.run_until_complete(make_request())
`

@sikelos
Copy link

sikelos commented Jan 13, 2023

@McMornan thanks for the code. Really really helpful !!
If you have found other similar requests please share them.
Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants