Method TogglePlayPauseAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
TogglePlayPauseAsync(CancellationToken)
Pauses the media when it plays, and plays it when it does not (it is paused, stopped, ended or not opened), and returns when the model shows it.
public Task<ObsMediaState> TogglePlayPauseAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token that ends the wait. A change that was not sent yet is not sent.
Returns
- Task<ObsMediaState>
A task that completes with the state that was asked for: Playing or Paused.
Remarks
OBS Studio has no request that toggles, so what the media does is asked in the turn of the change, when every change that was asked for before it has been answered: two toggles that are asked for one after the other make two toggles, whatever State shows meanwhile. A media that is opening or buffering is taken for playing.
Exceptions
- ObsRemovedException
The input 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.