ObsWebSocket class Null safety

Constructors

ObsWebSocket({required WebSocketChannel channel, Function? fallbackEvent})
When the object is created we open the websocket connection and create a broadcast stream so that we can have multiple listeners providing responses to commands. channel is an existing WebSocketChannel.

Properties

broadcast Stream
late, final
channel WebSocketChannel
final
eventHandlers Map<String, List<Function>>
final
fallbackHandlers List<Function>
final
hashCode int
The hash code for this object. [...]
read-only, inherited
message_id int
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addFallbackListener(Function listener) → void
add an event handler for an event that don't have a specific class
addHandler<T>(Function listener) → void
add an event handler for the event type T
authenticate(AuthRequiredResponse requirements, String passwd) Future<BaseResponse?>
Returns a BaseResponse object, requirements are provided by the AuthRequiredResponse object and passwd is the password assigned in the OBS interface for websockets. If OBS returns an error in the response, then an Exception will be thrown.
close() Future<void>
Before execution finished the websocket needs to be closed
command(String command, [Map<String, dynamic>? args]) Future<BaseResponse?>
This is a helper method for sending commands over the websocket. A SimpleResponse is returned. The function requires a command from the documented list of websocket and optionally args can be provided if required by the command. If OBS returns an error in the response, then an Exception will be thrown.
disableStudioMode() Future<void>
Disables Studio mode
enableStudioMode() Future<void>
Enables Studio Mode.
getAudioActive(String sourceName) Future<bool>
Get the audio's active status of a specified source.
getAuthRequired() Future<AuthRequiredResponse>
Returns an AuthRequiredResponse object that can be used to determine if authentication is required to connect to the server. The AuthRequiredResponse object hods the 'salt' and 'secret' that will be required for authentication in the case that it is required throws an Exception if there is a problem or error returned by the server. Returns an AuthRequiredResponse object.
getCurrentProfile() Future<CurrentProfileResponse>
Get the current profile
getCurrentScene() Future<Scene>
Get the current scene's name and source items. Returns a Scene object.
getMediaSourcesList() Future<MediaSourcesListResponse>
List the media state of all media sources (vlc and media source)
getMediaState([Map<String, dynamic>? args]) Future<MediaStateResponse>
Get the current playing state of a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8), Returns a MediaStateResponse object.
getSourceActive(String sourceName) Future<bool>
Get the source's active status of a specified source (if it is showing in the final mix).
getSourcesList() Future<SourcesListResponse>
List all sources available in the running OBS instance
getStreamSettings() Future<StreamSettingsResponse>
Get the current streaming server settings.
getStreamStatus() Future<StreamStatusResponse>
Get current streaming and recording status.
getStudioModeStatus() Future<StudioModeStatus>
Indicates if Studio Mode is currently enabled.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
pauseRecording() Future<void>
Pause the current recording. Returns an error if recording is not active or already paused.
playPauseMedia([Map<String, dynamic>? args]) Future<void>
Pause or play a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8) Note :Leaving out playPause toggles the current pause state
refreshBrowserSource(String sourceName) Future<void>
Refreshes the specified browser source.
removeFallbackListener(Function listener) → void
remove an event handler for an event that don't have a specific class
removeHandler<T>(Function listener) → void
remove an event handler for the event type T
restartMedia([Map<String, dynamic>? args]) Future<void>
Restart a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
resumeRecording() Future<void>
Resume/unpause the current recording (if paused). Returns an error if recording is not active or not paused.
saveStreamSettings() Future<void>
Save the current streaming server settings to disk.
sendCommand(Map<String, dynamic> payload, [Map<String, dynamic>? args]) String
This is the lower level send that transmits the command supplied on the websocket, It requires a payload, the command as a Map that will be json encoded in the format required by OBS, and the args. Both are combined into a single Map that is json encoded and transmitted over the websocket.
setCurrentProfile(String name) Future<void>
Set the current profile
setCurrentScene(String name) Future<void>
Switch to the specified scene.
setSceneItemRender(Map<String, dynamic> args) Future<void>
Show or hide a specified source item in a specified scene.
setStreamSettings(StreamSetting streamSetting) Future<void>
Sets one or more attributes of the current streaming server settings. Any options not passed will remain unchanged. Returns the updated settings in 'response'. If 'type' is different than the current streaming service type, all settings are required. Returns the full settings of the stream (the same as 'GetStreamSettings').
startRecording() Future<void>
Start recording. Will return an error if recording is already active.
startStopRecording() Future<void>
Toggle recording on or off (depending on the current recording state).
startStopStreaming() Future<void>
Toggle streaming on or off (depending on the current stream state).
startStreaming() Future<void>
Start streaming. Will return an error if streaming is already active.
stopMedia([Map<String, dynamic>? args]) Future<void>
Stop a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
stopRecording() Future<void>
Stop recording. Will return an error if recording is not active.
stopStreaming() Future<void>
Stop streaming. Will return an error if streaming is not active.
takeSourceScreenshot(TakeSourceScreenshot takeSourceScreenshot) Future<TakeSourceScreenshotResponse>
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Methods

connect({required String connectUrl, Function? fallbackEvent, Function? onError, Duration timeout = const Duration(seconds: 30)}) Future<ObsWebSocket>