Obs-Browser引入了一个由CEF(Chromium Embedded Framework)提供动力的跨平台浏览器源,向OBS Studio。浏览器源允许用户将基于Web的叠加层集成到他们的场景中,并完全访问现代Web API。
此外,OBS-BROWSER启用了服务集成(链接第三方服务)和浏览器码头(加载到接口本身中的网页),除Wayland(Linux)外,所有受支持的平台上都有。
该插件默认包含在Windows,MacOS,Ubuntu PPA和官方Flatpak(大多数Linux发行版)上的官方软件包上。
obs-browser提供了一个全局对象,该对象允许从JavaScript访问某些OBS特定功能。这可以用来创建一个动态适应于观察器的变化的覆盖层。
如果您使用的是打字稿,则可以通过NPM和纱线获得obs-browser绑定的类型定义。
# npm
npm install --save-dev @types/obs-studio
# yarn
yarn add --dev @types/obs-studio
/**
* @returns {string} OBS Browser plugin version
*/
window . obsstudio . pluginVersion
// => 2.17.0
/**
* @callback EventListener
* @param {CustomEvent} event
*/
/**
* @param {string} type
* @param {EventListener} listener
*/
window . addEventListener ( 'obsSceneChanged' , function ( event ) {
var t = document . createTextNode ( event . detail . name )
document . body . appendChild ( t )
} )
这些事件的描述可以在此处找到。
所需的权限:无
/**
* @typedef {number} Level - The level of permissions. 0 for NONE, 1 for READ_OBS (OBS data), 2 for READ_USER (User data), 3 for BASIC, 4 for ADVANCED and 5 for ALL
*/
/**
* @callback LevelCallback
* @param {Level} level
*/
/**
* @param {LevelCallback} cb - The callback that receives the current control level.
*/
window . obsstudio . getControlLevel ( function ( level ) {
console . log ( level )
} )
所需的权限:read_obs
/**
* @typedef {Object} Status
* @property {boolean} recording - not affected by pause state
* @property {boolean} recordingPaused
* @property {boolean} streaming
* @property {boolean} replaybuffer
* @property {boolean} virtualcam
*/
/**
* @callback StatusCallback
* @param {Status} status
*/
/**
* @param {StatusCallback} cb - The callback that receives the current output status of OBS.
*/
window . obsstudio . getStatus ( function ( status ) {
console . log ( status )
} )
所需的权限:read_user
/**
* @typedef {Object} Scene
* @property {string} name - name of the scene
* @property {number} width - width of the scene
* @property {number} height - height of the scene
*/
/**
* @callback SceneCallback
* @param {Scene} scene
*/
/**
* @param {SceneCallback} cb - The callback that receives the current scene in OBS.
*/
window . obsstudio . getCurrentScene ( function ( scene ) {
console . log ( scene )
} )
所需的权限:read_user
/**
* @callback ScenesCallback
* @param {string[]} scenes
*/
/**
* @param {ScenesCallback} cb - The callback that receives the scenes.
*/
window . obsstudio . getScenes ( function ( scenes ) {
console . log ( scenes )
} )
所需的权限:read_user
/**
* @callback TransitionsCallback
* @param {string[]} transitions
*/
/**
* @param {TransitionsCallback} cb - The callback that receives the transitions.
*/
window . obsstudio . getTransitions ( function ( transitions ) {
console . log ( transitions )
} )
所需的权限:read_user
/**
* @callback TransitionCallback
* @param {string} transition
*/
/**
* @param {TransitionCallback} cb - The callback that receives the transition currently set.
*/
window . obsstudio . getCurrentTransition ( function ( transition ) {
console . log ( transition )
} )
所需的权限:基本
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . saveReplayBuffer ( )
所需的权限:高级
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . startReplayBuffer ( )
所需的权限:高级
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . stopReplayBuffer ( )
所需的权限:高级
/**
* @param {string} name - Name of the scene
*/
window . obsstudio . setCurrentScene ( name )
所需的权限:高级
/**
* @param {string} name - Name of the transition
*/
window . obsstudio . setCurrentTransition ( name )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . startStreaming ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . stopStreaming ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . startRecording ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . stopRecording ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . pauseRecording ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . unpauseRecording ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . startVirtualcam ( )
所需的权限:全部
/**
* Does not accept any parameters and does not return anything
*/
window . obsstudio . stopVirtualcam ( )
这种方法是遗产。请注册事件听众。
/**
* onVisibilityChange gets callbacks when the visibility of the browser source changes in OBS
*
* @deprecated
* @see obsSourceVisibleChanged
* @param {boolean} visibility - True -> visible, False -> hidden
*/
window . obsstudio . onVisibilityChange = function ( visibility ) {
} ;
这种方法是遗产。请注册事件听众。
/**
* onActiveChange gets callbacks when the active/inactive state of the browser source changes in OBS
*
* @deprecated
* @see obsSourceActiveChanged
* @param {bool} True -> active, False -> inactive
*/
window . obsstudio . onActiveChange = function ( active ) {
} ;
obs-browser包括与obs-websocket的供应商请求集成。要使用的供应商名称是obs-browser
,可用请求是:
emit_event
获取event_name
和? event_data
参数。向所有浏览器源发出自定义事件。要订阅活动,请参见此处目前没有可用的供应商活动。
OBS浏览器不能独立构建。它是作为Obs Studio的一部分而构建的。
通过按照说明,这将在所有三个平台上启用浏览器源和自定义浏览器码头。 BUILD_BROWSER
和CEF_ROOT_DIR
都需要。
请按照构建说明进行操作,并确保下载CEF包装器并将CEF_ROOT_DIR
设置为CMAKE,以指向提取的包装器。
使用MacOS完整构建脚本。这将自动下载并启用OBS浏览器。
按照构建说明进行操作,然后选择“使用浏览器源构建”选项。这包括下载/提取CEF包装器的步骤,并设置所需的CMAKE变量。