use-obs-browser
v0.0.11
Published
Code layer allowing the use of obs-browser in React in a more "sexy" way.
Downloads
3
Maintainers
Readme
use-obs-browser
⚠️ Worked using npm link
, don't work as a true module, fix in progress ⚠️ |
A thin React hooks library to use the javascript API from the obs-browser source plugin (at the commit d1fa35dcbc384136e9e883f2d6071b14fd8f9a65)
install
In your project folder:
npm install --save-dev use-obs-browser
or the shorter: npm i -SD use-obs-browser
Philosophy
I didn't want to overcomplicate everything, it's just a collection of hooks that plugs straight into the obs-browser source plugin js API when the app is opened in OBS as a browser source.
Exemple: you want to get the version of the plugin you're running with ? Just:
import { useOBSVersion } from "use-obs-browser";
return () => <p>OBS Browser source plugin version: {useOBSVersion()}</p>;
Why all those hooks and not just functions ? Because at some point in the loading of the page by the obs-browser plugin there are few things missing, first the window
object, then event the obsstudio
object is not directly available. Plus there is the right management, like, you can't access the output status if the right to access them is not bestowed by the plugin.
There shouldn't be any error or exception, everything is made to run smoothly and if something is not working, or you just don't have the rights to do it, it just return the default or undefined
.
Outlines
CONTROL_LEVELS
, their list, indexes are important:["NONE", "OBS_STATE", "USER_INFORMATIONS", "BASIC", "ADVANCED", "TOTAL"];
hasAtLeastAccess
: take the index of a anCONTROL_LEVELS
and return a function that take an supposedCONTROL_LEVELS
index (integer) as argument and check if it's equal or bigger than the former one. Mainly serve as building all thehasAtLeast[CONTROL_LEVEL]Access
functions that ease the writing of access control code:hasAtLeastOBS_STATEAccess hasAtLeastUSER_INFORMATIONSAccess hasAtLeastBASICAccess hasAtLeastADVANCEDAccess hasAtLeastTOTALAccess
statesStates
is a state object that contain the various states possible of the various states of OBS (yo dawg), so, in order, because the indexes are important:{ "recording": ["stopped", "starting", "started", "paused", "stopping"], "replaybuffer": ["stopped", "starting", "started", "saved", "stopping"], "streaming": ["stopped", "starting", "started", "stopping"], "virtualcam": ["stopped", "started"] }
useOBSBrowser
: return theobsstudio
object.useOBSControlLevel
: return the currentcontrolLevel
.useOBSCurrentScene
: require theUSER_INFORMATIONS
control level, return thecurrentScene
onject, containing:{ height: [height of the scene in pixels], width: [width of the scene in pixels], name: [name of the scene] }
.useOBSCurrentTransition
: require theUSER_INFORMATIONS
control level, return thecurrentTransition
name.useOBSoutputStatus
: require theOBS_STATE
control level, return the object containing the various status of the various outputs, seestatesStates
. By default:{ recording: "stopped", replaybuffer: "stopped", streaming: "stopped", virtualcam: "stopped" }
useOBSScenes
: require theUSER_INFORMATIONS
control level, return the array containing the various scenes name available.useOBSTransitions
: require theUSER_INFORMATIONS
control level, return the array containing the various transitions name available.useOBSVersion
: return the version string of the current OBS Browser source plugin.
[TO BE CONTINUED]