diff --git a/browser-client.cpp b/browser-client.cpp index d91ca7024..4ca339c07 100644 --- a/browser-client.cpp +++ b/browser-client.cpp @@ -648,6 +648,12 @@ void BrowserClient::OnAudioStreamStopped(CefRefPtr browser, int id) } #endif +void BrowserClient::OnLoadStart(CefRefPtr browser, + CefRefPtr, TransitionType) +{ + browser->GetHost()->SetZoomLevel(bs->zoom); +} + void BrowserClient::OnLoadEnd(CefRefPtr, CefRefPtr frame, int) { diff --git a/browser-client.hpp b/browser-client.hpp index cbff1201e..1e3178712 100644 --- a/browser-client.hpp +++ b/browser-client.hpp @@ -179,6 +179,10 @@ class BrowserClient : public CefClient, int frames_per_buffer) override; #endif /* CefLoadHandler */ + virtual void OnLoadStart(CefRefPtr browser, + CefRefPtr frame, + TransitionType transition_type) override; + virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) override; diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 188958efe..53ffbfc29 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -187,6 +187,8 @@ static obs_properties_t *browser_source_get_properties(void *data) 8192, 1); obs_properties_add_int(props, "height", obs_module_text("Height"), 1, 8192, 1); + obs_properties_add_int(props, "zoom", obs_module_text("Zoom"), -6, 9, + 1); obs_properties_add_bool(props, "reroute_audio", obs_module_text("RerouteAudio")); diff --git a/obs-browser-source.cpp b/obs-browser-source.cpp index 09b301718..13f04b787 100644 --- a/obs-browser-source.cpp +++ b/obs-browser-source.cpp @@ -512,6 +512,7 @@ void BrowserSource::Update(obs_data_t *settings) bool n_is_local; int n_width; int n_height; + int n_zoom; bool n_fps_custom; int n_fps; bool n_shutdown; @@ -524,6 +525,7 @@ void BrowserSource::Update(obs_data_t *settings) n_is_local = obs_data_get_bool(settings, "is_local_file"); n_width = (int)obs_data_get_int(settings, "width"); n_height = (int)obs_data_get_int(settings, "height"); + n_zoom = (int)obs_data_get_int(settings, "zoom"); n_fps_custom = obs_data_get_bool(settings, "fps_custom"); n_fps = (int)obs_data_get_int(settings, "fps"); n_shutdown = obs_data_get_bool(settings, "shutdown"); @@ -582,11 +584,13 @@ void BrowserSource::Update(obs_data_t *settings) n_reroute == reroute_audio && n_webpage_control_level == webpage_control_level) { - if (n_width == width && n_height == height) + if (n_width == width && n_height == height && + n_zoom == zoom) return; width = n_width; height = n_height; + zoom = n_zoom; ExecuteOnBrowser( [=](CefRefPtr cefBrowser) { const CefSize cefSize(width, height); @@ -596,6 +600,8 @@ void BrowserSource::Update(obs_data_t *settings) ->OnAutoResize(cefBrowser, cefSize); cefBrowser->GetHost()->WasResized(); + cefBrowser->GetHost()->SetZoomLevel( + zoom); cefBrowser->GetHost()->Invalidate( PET_VIEW); }, @@ -606,6 +612,7 @@ void BrowserSource::Update(obs_data_t *settings) is_local = n_is_local; width = n_width; height = n_height; + zoom = n_zoom; fps = n_fps; fps_custom = n_fps_custom; shutdown_on_invisible = n_shutdown; diff --git a/obs-browser-source.hpp b/obs-browser-source.hpp index 7c77f2e6d..e3d9bb92e 100644 --- a/obs-browser-source.hpp +++ b/obs-browser-source.hpp @@ -81,6 +81,7 @@ struct BrowserSource { int width = 0; int height = 0; + int zoom = 0; bool fps_custom = false; int fps = 0; double canvas_fps = 0;