OBS control from webpage buttons not working

Duncanorak

New Member
Hi I wonder if any clever people out there can help me? I have this html code along with web-sockets.js that should change the scene when I press the button on the website. It connects to websocket but appears to send no information (this is me interpreting what websocket is displaying). I think the commands are correct, the function names seem to be correct as they work in obs-raw.streamer.bot and do indeed select the correct seen.
Many thanks in advance.
Here a screen shots of Websocket and obs-raw.streamer.bot and also the HTML code.
Websocket.png
obs-raw.streamer.bot.png

<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="http://127.0.0.1/obs-websocket.js"></script>
<title>WEBSOCKET TEST</title>
</head>


<body>



<a align="center" href="#" onclick="SetCurrentProgramScene('SCENE-NAME-ON-OBS')">Cam1</a>

<script>
function SetCurrentProgramScene(sceneName)
{const obs = new OBSWebSocket();
obs.connect({address: '127.0.0.1:4455'});

obs.on('ConnectionOpened', () => {obs.call('SetCurrentProgramScene', {'sceneName': Cam1 });
});
}

</script>

</body>
</html>
 

yukon92

Member
I fought with this.
Try this code instead:

{
"op": 6,
"d": {
"requestType": "SetCurrentProgramScene",
"requestId": "1234",
"requestData": {
"sceneName": "Scene Name"
}
}
}
 

Duncanorak

New Member
Thanks Yukon92
but I can't get that to work. I'm not sure where I should be putting this in my html code. I have tried various places but nothing works, websocket doesn't even show a connection.
Any pointers as to where I should put this within my html code.

Thanks
 
Top