<!DOCTYPE html>
<html>
<head>
<title>OBS Text Update</title>
</head>
<body>
<div>
<label for="textSource">Text Source:</label>
<input type="text" id="textSource" value="test">
</div>
<div>
<label for="newText">New Text:</label>
<input type="text" id="newText" value="1">
</div>
<div>
<button id="updateText">Update Text</button>
</div>
<script src="
https://cdn.jsdelivr.net/npm/obs-websocket-js/dist/obs-websocket.min.js"></script>
<script>
const obs = new OBSWebSocket();
document.getElementById('updateText').addEventListener('click', async () => {
try {
await obs.connect({
address: 'localhost:4444',
password: 'passwd'
});
console.log(`Connected to OBS Studio!`);
const sourceName = document.getElementById('textSource').value;
const newText = document.getElementById('newText').value;
const response = await obs.send('SetTextGDIPlusProperties', {
'source': sourceName,
'text': newText
});
if (response.status === 'ok') {
console.log(`Text updated successfully for source: ${sourceName}`);
} else {
console.error(`Error updating text: ${JSON.stringify(response, null, 2)}`);
}
} catch (error) {
console.error(`Failed to connect to OBS Studio: ${error}`);
} finally {
obs.disconnect();
console.log(`Disconnected from OBS Studio.`);
}
});
</script>
</body>
</html>