Table of Contents

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
object
Player

Properties

Duration

Media length, seconds.

public double Duration { get; }

Property Value

double

Fps

Media frame rate, or null when no media is loaded.

public double? Fps { get; }

Property Value

double?

IsPlaying

Whether playback is running. Set to play/pause.

public bool IsPlaying { get; set; }

Property Value

bool

MediaPath

Path of the loaded media, or "" if none.

public string MediaPath { get; }

Property Value

string

Speed

Playback rate, e.g. 1.0.

public float Speed { get; set; }

Property Value

float

Time

Current playback position, seconds.

public double Time { get; }

Property Value

double

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

float

Methods

Seek(ScriptAction)

Seeks the playhead to time seconds. Main-thread only.

public void Seek(ScriptAction action)

Parameters

action ScriptAction

Seek(double)

Seeks the playhead to time seconds. Main-thread only.

public void Seek(double time)

Parameters

time double

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

Action<string>

PlayingChanged

Raised when playback starts or stops; the argument is true while playing.

public event Action<bool>? PlayingChanged

Event Type

Action<bool>

SpeedChanged

Raised when the playback speed changes; the argument is the new rate (1.0 = normal).

public event Action<float>? SpeedChanged

Event Type

Action<float>

TimeChanged

Raised as playback advances; the argument is the new time in seconds.

public event Action<double>? TimeChanged

Event Type

Action<double>