obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
769 stars 217 forks source link

Add function to resize the browser source from JavaScript #423

Open exeldro opened 10 months ago

exeldro commented 10 months ago

Description

Add function to resize the browser source from javascript

Motivation and Context

Allows browser sources to be sized to exactly fit its contents. This can be very useful for my Markdown Source plugin.

How Has This Been Tested?

On windows 11 64 bit using Markdown Source with the following javascript:

    let size = document.body.getBoundingClientRect();
    window.obsstudio.setBrowserSize(Math.ceil(size.width), Math.ceil(size.height));

Types of changes

Checklist:

Warchamp7 commented 3 months ago

What's the use case for adding a new obs-browser js binding over say using obs-websockets? Is it just the hurdle of connecting to obs-ws?

Ever since obs-ws was made a core plugin I'm generally against adding new obs-browser bindings to avoid maintaining essentially two browser source APIs.

At the very least, I think a better approach here would be a more abstract system that allows browser sources to dispatch() an event to OBS plugins. Then your plugin could handle the source resizing in response to that event.