Table of Contents

Method SwitchToPreviewAsync

Namespace
OBSStudioClient.Model
Assembly
OBSClient.dll

SwitchToPreviewAsync(CancellationToken)

Makes the scene the preview scene of studio mode (the one that becomes the program scene when the transition is triggered), and returns when the model shows it.

public Task SwitchToPreviewAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

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

Returns

Task

A task that completes when IsPreview is true, or when the model has been read again after the events did not show it.

Remarks

OBS Studio keeps a preview scene only while studio mode is on (SetStudioModeEnabledAsync(bool, CancellationToken)), and refuses the request while it is off. It sends no event when the scene is the preview scene already. See SetEnabledAsync(bool, CancellationToken) for the order of changes and the wait.

Exceptions

InvalidOperationException

The scene is a group (IsGroup): a group is not a scene that can be shown.

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 change.

ObsNotConfirmedException

OBS Studio made the change, and the model does not show it: the events did not show it in time, and the model could not be read again in time. Do not send the change again.

ObsResponseException

OBS Studio refused the change: studio mode is off (ErrorCode is StudioModeNotActive).