obsproject / obs-browser

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

Uncaught TypeError: window.obsstudio.setCurrentScene is not a function #347

Closed Deuchnord closed 2 years ago

Deuchnord commented 2 years ago

Operating System Info

Other

Other OS

Arch Linux

OBS Studio Version

27.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/2yZ1fpEsv5tg44Fl

OBS Studio Crash Log URL

No response

Expected Behavior

In a browser source that has the "Advanced" permission, when the JavaScript window.obsstudio.setCurrentScene() function is called, it OBS changes the scene to the one given in parameter.

Current Behavior

Nothing happens in OBS Studio, and the following error appears in the console:

Uncaught TypeError: window.obsstudio.setCurrentScene is not a function

When calling console.log(window.obsstudio) in the console, we can see that there is no such function called setCurrentScene(), so this sounds more like a documentation issue.

Steps to Reproduce

  1. Create the following HTML file:
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <script type="text/javascript">
          setTimeout(() => {
              window.obsstudio.setCurrentScene('TargetScene');
          }, 3000);
        </script>
    </body>
    </html>
  2. Create a scene with a browser source and load the HTML file in it.
  3. Create a second scene and name it 'TargetScene'.
  4. Display the first scene. Wait 3 seconds: nothing happens.

Anything else we should know?

No response

gxalpha commented 2 years ago

SetCurrentScene is only available with 27.2. Try using the Beta version of OBS, it should be available there.