Class ObsMedia
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
The playback of a media input of OBS Studio (a media source or a VLC video source): what it is doing, and the calls that play, pause, stop, restart and seek it.
public sealed class ObsMedia : INotifyPropertyChanged
- Inheritance
-
ObsMedia
- Implements
- Inherited Members
Remarks
A media input has one: Media is null for an input that is no media input. The object stays the same for as long as the input exists.
State is kept current by the events that OBS Studio sends about playback, and the calls that change it return when the model shows the change (see SetEnabledAsync(bool, CancellationToken) for the order of changes and the wait). The position and the length of the media are not in the model: they move all the time, and OBS Studio sends no event for them, so ask GetStatusAsync(CancellationToken) when you need them.
What OBS Studio does (measured with OBS Studio 33.0.0): a media source that restarts when it is shown (the default) is not opened while its scene is not on the program output: its state is None until it is told to play or pause, or until the scene is shown. Showing the scene plays it from the start, and when it is not shown any more it ends (unless the setting of the source says otherwise). A source that does not restart when it is shown is opened, and plays, as soon as it is made. The model follows all of it like any other change of the state.
The position changes only for a media that plays and is shown, see SeekAsync(TimeSpan, CancellationToken).
Properties
- Input
Gets the input that plays the media.
- State
Gets what the media is doing. The value is current: OBS Studio announces what matters (it plays, it is paused or stopped, it ended). It does not show Opening, Buffering and Error after the model has read it, because OBS Studio does not announce them: see GetStatusAsync(CancellationToken).
Methods
- GetStatusAsync(CancellationToken)
Asks OBS Studio what the media is doing, how long it is, and where it is.
- NextAsync(CancellationToken)
Goes to the next item of the playlist of the media input, and returns when OBS Studio has answered.
- PauseAsync(CancellationToken)
Pauses the media, and returns when the model shows that it is paused.
- PlayAsync(CancellationToken)
Plays the media, and returns when the model shows that it plays.
- PreviousAsync(CancellationToken)
Goes to the previous item of the playlist of the media input, and returns when OBS Studio has answered.
- RestartAsync(CancellationToken)
Plays the media from the beginning, and returns when the model shows that it plays.
- SeekAsync(TimeSpan, CancellationToken)
Moves the media to a position, and returns when OBS Studio has answered.
- SkipAsync(TimeSpan, CancellationToken)
Moves the media forwards or backwards from where it is, and returns when OBS Studio has answered.
- StopAsync(CancellationToken)
Stops the media, and returns when the model shows that it is stopped.
- ToString()
Returns a string that represents the current object.
- 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.
Events
- PropertyChanged
Occurs when a property value changes.