Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Retrieving values from OBS #280

Unanswered
mccombey asked this question in Q&A
Discussion options

I've been successfully controlling OBS using obs-websocket-js and it works fantastically well. However, I have no idea how to retrieve values from OBS using code. I've looked everywhere and there are no examples of syntax. Functions like GetTextGDIPlusProperties are there, but how do I use them?

This is how I'm currently using the obs-websocket-js to send commands...

const obs = new OBSWebSocket();
	obs.connect({
		address: "localhost:4444"
	});
obs.send("SetCurrentScene", {
 "scene-name": "titles"		
});	

Any help would be most appreciated!

You must be logged in to vote

Replies: 1 comment

Comment options

.send function calls return a Promise that resolve when obs-websocket answers to the request. Therefore the data can be accessed by

.then on promise chain:

// SetCurrentScene returns an empty object on resolve, so while you can use the callback to know when scene has been set, Get works as a better example:
obs.send("GetCurrentScene").then((data) => {
	console.log(data.name); // Current scene name
});

Alternatively there's also async/await syntax:

// Generally should be in a async function like
// async function checkCurrentScene() {
const data = await obs.send("GetCurrentScene");
console.log(data.name); // Current scene name
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /