Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ Permissions required: ALL
window.obsstudio.stopVirtualcam()
```

#### Set the browser size
Permissions required: BASIC
```js
/**
* @param {int} width - Width of the browser size
* @param {int} height - Height of the browser size
*/
window.obsstudio.setBrowserSize(width, height)
```

### Register for visibility callbacks

Expand Down
14 changes: 7 additions & 7 deletions browser-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ void BrowserApp::OnBeforeCommandLineProcessing(const CefString &, CefRefPtr<CefC
#endif
}

std::vector<std::string> exposedFunctions = {"getControlLevel", "getCurrentScene", "getStatus",
"startRecording", "stopRecording", "startStreaming",
"stopStreaming", "pauseRecording", "unpauseRecording",
"startReplayBuffer", "stopReplayBuffer", "saveReplayBuffer",
"startVirtualcam", "stopVirtualcam", "getScenes",
"setCurrentScene", "getTransitions", "getCurrentTransition",
"setCurrentTransition"};
std::vector<std::string> exposedFunctions = {"getControlLevel", "getCurrentScene", "getStatus",
"startRecording", "stopRecording", "startStreaming",
"stopStreaming", "pauseRecording", "unpauseRecording",
"startReplayBuffer", "stopReplayBuffer", "saveReplayBuffer",
"startVirtualcam", "stopVirtualcam", "getScenes",
"setCurrentScene", "getTransitions", "getCurrentTransition",
"setCurrentTransition", "setBrowserSize"};

void BrowserApp::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame>, CefRefPtr<CefV8Context> context)
{
Expand Down
19 changes: 19 additions & 0 deletions browser-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ bool BrowserClient::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefR
case ControlLevel::Basic:
if (name == "saveReplayBuffer") {
obs_frontend_replay_buffer_save();
} else if (name == "setBrowserSize") {
int width = input_args->GetInt(1);
int height = input_args->GetInt(2);
if (!width)
width = (int)round(input_args->GetDouble(1));
if (!height)
height = (int)round(input_args->GetDouble(2));
if (width > 0 && height > 0) {
OBSDataAutoRelease s = obs_source_get_settings(bs->source);
if (s && (obs_data_get_int(s, "width") != width ||
obs_data_get_int(s, "height") != height)) {
obs_data_set_int(s, "width", width);
obs_data_set_int(s, "height", height);
obs_source_update(bs->source, s);
}
} else {
blog(LOG_WARNING, "Browser source '%s' tried to change its size to %ix%i",
obs_source_get_name(bs->source), width, height);
}
}
[[fallthrough]];
case ControlLevel::ReadUser:
Expand Down