Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a display #623

Closed
hrueger opened this issue Apr 16, 2020 · 6 comments
Closed

How to create a display #623

hrueger opened this issue Apr 16, 2020 · 6 comments

Comments

@hrueger
Copy link
Contributor

hrueger commented Apr 16, 2020

Hi,
with the help of this repository, I was able to get the basic setup with electron working.
However, for now just adding scenes, sources and recording works. I'd like to add a output display.
In streamlabs-obs I found this code: https://github.com/stream-labs/streamlabs-obs/blob/e707f9819a10296893f4d3e058d12110c1ec44a7/app/services/video.ts#L254-L275
So I have the following code:

const osn = require("obs-studio-node");
 // do all the initialization stuff, like here: https://github.com/Envek/obs-studio-node-example/blob/a099849c5e053cced4cfb23f9a250f95e5c7967f/obsRecorder.js#L10-L64
const t = new BrowserWindow({
    height: 300,
    width: 400,
    webPreferences: {
      nodeIntegration: true,
    }
  });

  osn.NodeObs.OBS_content_createDisplay(
    t.getNativeWindowHandle(),
    "test",
    1,
  );

But it just gives me the normal BrowserWindow.
Rendering mode can be 0, 1 or 2 as defined here but it doesn't work with any of them.

What am I missing or doing wrong?

@hrueger
Copy link
Contributor Author

hrueger commented Apr 19, 2020

Sorry for another ping, but it's a great library and it would be very helpful if someone could just post a simple example for creating a display.
As you can tell from #578 there are quite some people who are interested in knowing how to use the library.

@hrueger
Copy link
Contributor Author

hrueger commented May 6, 2020

Thank you!

@hrueger hrueger closed this as completed May 6, 2020
@aza547
Copy link

aza547 commented Apr 28, 2023

I'm struggling with this also, was there a solution?

@hrueger
Copy link
Contributor Author

hrueger commented Apr 28, 2023

@aza547
Copy link

aza547 commented Apr 30, 2023

Thanks! I've been referencing these docs a lot - thanks for creating them. The bit I was missing was the resize, seems that it never gets drawn on the window without the call to osn.NodeObs.OBS_content_resizeDisplay().

I'm now facing another two problems:

  1. The display is always on-top of the window. I'd like to allow menus / tooltips to overlay it. Any idea if it's possible?
    image

  2. The call to OBS_Content_destroyDisplay to hide the display seems to freeze up my program. I've hacked around it for now with this, but bit nervous about leaving it like that.

    // I'd love to make OBS_content_destroyDisplay work here but I've not managed
    // so far. This is a hack to "hide" it by moving it off screen.
    osn.NodeObs.OBS_content_moveDisplay(this.previewName, 50000, 50000);

@aza547
Copy link

aza547 commented Apr 30, 2023

Seems like 1 is answered here:
#1229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants