Class Player
- Namespace
- Ofs
- Assembly
- Ofs.Api.dll
Playback state, commands and events. State is exposed as properties; commands are methods; notifications are events. All members must be touched on the main thread.
public sealed class Player
- Inheritance
-
objectPlayer
Properties
Duration
Media length, seconds.
public double Duration { get; }
Property Value
Fps
Media frame rate, or null when no media is loaded.
public double? Fps { get; }
Property Value
IsPlaying
Whether playback is running. Set to play/pause.
public bool IsPlaying { get; set; }
Property Value
MediaPath
Path of the loaded media, or "" if none.
public string MediaPath { get; }
Property Value
Speed
Playback rate, e.g. 1.0.
public float Speed { get; set; }
Property Value
Time
Current playback position, seconds.
public double Time { get; }
Property Value
VideoHeight
Video frame height in pixels, or null when no video is loaded.
public int? VideoHeight { get; }
Property Value
- int?
VideoWidth
Video frame width in pixels, or null when no video is loaded.
public int? VideoWidth { get; }
Property Value
- int?
Volume
Playback volume, 0..1. Reads 0 when no media is loaded.
public float Volume { get; set; }
Property Value
Methods
Seek(ScriptAction)
Seeks the playhead to time seconds. Main-thread only.
public void Seek(ScriptAction action)
Parameters
actionScriptAction
Seek(double)
Seeks the playhead to time seconds. Main-thread only.
public void Seek(double time)
Parameters
timedouble
TogglePlay()
Toggles between play and pause. Main-thread only.
public void TogglePlay()
Events
MediaChanged
Raised when a different media file loads; the argument is its path.
public event Action<string>? MediaChanged
Event Type
PlayingChanged
Raised when playback starts or stops; the argument is true while playing.
public event Action<bool>? PlayingChanged
Event Type
SpeedChanged
Raised when the playback speed changes; the argument is the new rate (1.0 = normal).
public event Action<float>? SpeedChanged
Event Type
TimeChanged
Raised as playback advances; the argument is the new time in seconds.
public event Action<double>? TimeChanged