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變量。