Method AddAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
AddAsync(ObsSource, bool, CancellationToken)
Shows a scene or an input in the scene (makes a scene item for it, on top), and returns the scene item when the model shows it.
public Task<ObsSceneItem> AddAsync(ObsSource source, bool enabled = true, CancellationToken cancellationToken = default)
Parameters
sourceObsSourceThe scene or the input to show. A scene that would contain itself, directly or through the scenes that it contains, is refused by OBS Studio.
enabledboolWhether the scene item is shown.
cancellationTokenCancellationTokenA token that ends the wait. A change that was not sent yet is not sent.
Returns
- Task<ObsSceneItem>
The scene item, which is in Items.
Remarks
The same source can be in a scene several times: each call makes another scene item. See SetEnabledAsync(bool, CancellationToken) for the order of changes and the wait.
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis this scene, or belongs to another ObsModel.- InvalidOperationException
This scene is a group (IsGroup): obs-websocket makes scene items in scenes only, not in a group. Nothing was changed.
- ObsRemovedException
The scene or the source was removed.
- ObsNotConnectedException
There is no connection to OBS Studio. Nothing was changed.
- ObsNotReadyException
OBS Studio is changing its scene collection, or did so after the call. Nothing was changed.
- ObsUnknownOutcomeException
OBS Studio did not answer in time, or the connection ended: it is not known whether it made the scene item.
- ObsNotConfirmedException
OBS Studio made the scene item, and the model does not show it. Do not send the change again.
- ObsResponseException
OBS Studio refused the change (for example because the scene would contain itself).