obs-browser icon indicating copy to clipboard operation
obs-browser copied to clipboard

obs-browser does not expose method to obtain active status before events are fired

Open xaroth opened this issue 5 years ago • 13 comments

Platform

Operating system and version: Not OS-dependent OBS Studio version: master

Current Behavior

When the browser context is created, and the page is loaded, the obs-browser source exposes various bits of information, either via the JS API, or via other properties that can be accessed via JS (like the document visibility marker). One exception to this is the active status of the source. From what I can see (and what is documented), the only way of seeing this information during events being fired, however, if the scene is already active while the context is being created, there is no way of knowing that the source is active.

Additional information

The JS API exposes the following bits of information through events:

  • Recorder status
  • Replay buffer status
  • Streaming output status
  • Current scene info (name, height, width)
  • Visibility status (Whether we're part of a visible scene)
  • Active status (Whether we're part of an active scene)

Outside events, the following information can be obtained:

Visibility status

During BrowserApp::OnContextCreated, SetDocumentVisibility is triggered to ensure that the document.visibility (on all frames) is set to either "visible" or "hidden". While this is not an ideal bool you can test with directly, it having only two values makes it usable.

Recorder/Replay/Streaming status

One can use window.obsstudio.getStatus() to obtain the current status for the recorder, replay buffer and streaming output.

Scene information

window.obsstudio.getCurrentScene() can be used to obtain the scene information.

Suggested fix

I would suggest updating window.obsstudio.getStatus to also include the visible and active status. this ensures that both properties are directly available from obs-browser through a callback, without having to parse visibility status.

xaroth avatar Dec 09 '20 15:12 xaroth