Table of Contents

Method CreateInputAsync

Namespace
OBSStudioClient.Model
Assembly
OBSClient.dll

CreateInputAsync(string, string, object?, bool, CancellationToken)

Makes an input in the scene (and a scene item that shows it), and returns the input when the model shows both.

public Task<ObsInput> CreateInputAsync(string name, string kind, object? settings = null, bool enabled = true, CancellationToken cancellationToken = default)

Parameters

name string

The name of the new input: it can not be the name of another input or of a scene.

kind string

The kind of the input, for example color_source_v3, image_source or wasapi_input_capture. GetInputKindList(bool?, CancellationToken) lists them.

settings object

The settings of the new input: an object whose fields are the settings of its kind (for example new { width = 640, height = 360 }; the names are used as they are written, and OBS Studio's settings have lower case names), or null for the defaults of the kind.

enabled bool

Whether the scene item that shows the input is shown.

cancellationToken CancellationToken

A token that ends the wait. A change that was not sent yet is not sent.

Returns

Task<ObsInput>

The input, which is in Inputs; its scene item is in Items (GetSceneItems() of the input finds it), unless somebody removed it meanwhile.

Remarks

The call returns when the model shows the input and its scene item, so that what you read next is what you made. See SetEnabledAsync(bool, CancellationToken) for the order of changes and the wait. The input is a new object of the model: it is complete (with its audio state) when you get it.

Exceptions

ArgumentException

name or kind is empty, or settings is not an object (a CancellationToken passed in its place is refused with a message that says so: pass it as cancellationToken), or can not be written as JSON.

InvalidOperationException

The scene is a group (IsGroup): obs-websocket makes inputs in scenes only, not in a group. Nothing was changed.

ObsNameInUseException

The name is taken (by a scene, by an input, by a group, or by an input that was removed and that OBS Studio keeps alive). Nothing was changed.

ObsRemovedException

The scene 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 input.

ObsNotConfirmedException

OBS Studio made the input, and the model does not show it. Do not send the change again.

ObsResponseException

OBS Studio refused the change (for example because it has no input of that kind).