Skip to content

Node.js npm module. Using obs-websocket-js to automate our live stream. See Automations in action on:

License

Notifications You must be signed in to change notification settings

web3nelly/change-obs-scene

Repository files navigation

@b3nelly/change-obs-scene Node.js npm Package

With just a few lines of code, automate changing your OBS scenes using the @b3nelly/change-obs-scene npm package. 💜

Dependancies

Installation

npm install @b3nelly/change-obs-scene

Usage

First, launch OBS and enable the WebSocket Server

Tools > WebSocket Server Settings:

  • obs websocket server settings image
  • Don't forget to set your Server Password
  • If you do not set a password, you do not need to pass the obsWebSocketServerPassword param to changeScene()

Simple Usage Example

const changeScene = require("@b3nelly/change-obs-scene").default;
const intervalInSeconds = 30; // 30 seconds per scene
changeScene(intervalInSeconds); // it's that simple.

CommonJS (cjs) Usage Example

const changeScene = require("@b3nelly/change-obs-scene").default;

const obsSkipScenes = [];
const intervalInSeconds = 30;
const obsWebSocketServerPassword = "your-password-here";
const obsWebSocketServerURL = "ws://localhost:4455";

changeScene(
  intervalInSeconds,
  obsSkipScenes,
  obsWebSocketServerPassword,
  obsWebSocketServerURL
);

ECMAScript Module (esm) Usage Example

import changeScene from "@b3nelly/change-obs-scene";

const obsSkipScenes = [];
const intervalInSeconds = 30;
const obsWebSocketServerPassword = "your-password-here";

changeScene(intervalInSeconds, obsSkipScenes, obsWebSocketServerPassword);

Asynchronous Module Definition (amd) Usage Example

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>AMD Example</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
    <script>
      require.config({
        paths: {
          changeScene: "@b3nelly/change-obs-scene/dist/change-obs-scene.amd",
        },
      });

      require(["changeScene"], function (changeScene) {
        const obsSkipScenes = [];
        const intervalInSeconds = 90;
        const obsWebSocketServerPassword = "your-password-here";

        changeScene(
          intervalInSeconds,
          obsSkipScenes,
          obsWebSocketServerPassword
        );
      });
    </script>
  </head>
  <body></body>
</html>

API

changeScene(
  intervalInSeconds,
  obsSkipScenes,
  obsWebSocketServerPassword,
  obsWebSocketServerURL
);
Parameter Type Default Description
intervalInSeconds (optional) number 60 Number of seconds between each scene
obsSkipScenes (optional) Array<string> [] An array of scene names to skip when switching scenes
obsWebSocketServerPassword (optional) string undefined OBS WebSocket Server Password
obsWebSocketServerURL (optional) string "ws_://localhost:4455" OBS WebSocket Server URL / IP

change-obs-scene In Action

Working change obs scene example image

CLI

npm run cli

You will be prompted to enter in the changeSence() params. Leave param blank to use default value.

Build

npm run build

Running the build command will automatically create the dist/ dir and create/update the cjs, esm, and amd files inside.

Configuration file rollup.config.js

Development Dependancies

License

MIT

This README.md file provides installation and usage instructions, as well as a brief description of the API for the @b3nelly/change-obs-scene package. Feel free to modify it as needed.