Table of Contents

Interface IMediaPlayerControls

Namespace
VisioForge.Core.Types
Assembly
VisioForge.Core.dll

Defines a standard set of controls for a media player component. This interface provides a common API for controlling playback of media files, including play, pause, stop, seek, and volume adjustments. It also includes asynchronous versions of most methods for use in responsive UI applications.

public interface IMediaPlayerControls : IVideoEffectsControls

Implements

Remarks

This interface inherits from VisioForge.Core.Types.IVideoEffectsControls, providing access to video effect adjustments in addition to playback controls. Implementations of this interface are expected to manage the underlying media playback engine (GStreamer, Media Foundation, FFmpeg, etc.). All asynchronous methods return Task objects to support modern async/await programming patterns. The interface supports both synchronous and asynchronous operations to accommodate different programming styles and scenarios. Position and duration are represented using TimeSpan for precise timing control. The State property provides real-time status of the player (Playing, Paused, Stopped).

Properties

State

Gets the current playback state of the media player (e.g., Playing, Paused, Stopped).

PlaybackState State { get; }

Property Value

PlaybackState

Methods

Duration()

Gets the total duration of the media.

TimeSpan Duration()

Returns

TimeSpan

A TimeSpan representing the media's duration.

DurationAsync()

Asynchronously gets the total duration of the media.

Task<TimeSpan> DurationAsync()

Returns

Task<TimeSpan>

A task that represents the asynchronous operation. The task result contains the media's duration as a TimeSpan.

GetFileThumbnail(string)

Extracts a thumbnail image from a specified media file.

SKBitmap GetFileThumbnail(string filename)

Parameters

filename string

The path to the media file.

Returns

SKBitmap

An SkiaSharp.SKBitmap containing the thumbnail image, or null if a thumbnail could not be extracted.

NextFrame()

Advances playback to the next frame. This is useful for frame-by-frame analysis.

bool NextFrame()

Returns

bool

true if the operation is successful, false otherwise.

OpenAsync(string)

Asynchronously opens a media file from a specified path.

Task<bool> OpenAsync(string path)

Parameters

path string

The file path or URL of the media to open.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if the file was opened successfully, false otherwise.

Pause()

Pauses the currently playing media.

bool Pause()

Returns

bool

true if the operation is successful, false otherwise.

PauseAsync()

Asynchronously pauses the currently playing media.

Task<bool> PauseAsync()

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if successful, false otherwise.

Play(bool)

Starts or preloads the media for playback.

bool Play(bool onlyPreload = false)

Parameters

onlyPreload bool

If set to true, the media is loaded and ready to play but does not start automatically.

Returns

bool

true if the operation is successful, false otherwise.

PlayAsync(bool)

Asynchronously starts or preloads the media for playback.

Task<bool> PlayAsync(bool onlyPreload = false)

Parameters

onlyPreload bool

If set to true, the media is loaded and ready to play but does not start automatically.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if successful, false otherwise.

Position_Get()

Gets the current playback position.

TimeSpan Position_Get()

Returns

TimeSpan

A TimeSpan representing the current position.

Position_GetAsync()

Asynchronously gets the current playback position.

Task<TimeSpan> Position_GetAsync()

Returns

Task<TimeSpan>

A task that represents the asynchronous operation. The task result contains the current position as a TimeSpan.

Position_Set(TimeSpan, bool)

Sets the current playback position to a specified time.

void Position_Set(TimeSpan position, bool seekToKeyframe = false)

Parameters

position TimeSpan

The time to seek to.

seekToKeyframe bool

If set to true, the seek will be to the nearest keyframe, which is faster but less precise.

Position_SetAsync(TimeSpan, bool)

Asynchronously sets the current playback position to a specified time.

Task Position_SetAsync(TimeSpan position, bool seekToKeyframe = false)

Parameters

position TimeSpan

The time to seek to.

seekToKeyframe bool

If set to true, the seek will be to the nearest keyframe, which is faster but less precise.

Returns

Task

A task that represents the asynchronous operation.

PrevFrame()

Moves playback to the previous frame. This is useful for frame-by-frame analysis.

bool PrevFrame()

Returns

bool

true if the operation is successful, false otherwise.

Resume()

Resumes playback from a paused state.

bool Resume()

Returns

bool

true if the operation is successful, false otherwise.

ResumeAsync()

Asynchronously resumes playback from a paused state.

Task<bool> ResumeAsync()

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if successful, false otherwise.

SetSpeed(double)

Sets the playback speed.

bool SetSpeed(double speed)

Parameters

speed double

The playback speed, where 1.0 is normal speed, 0.5 is half speed, and 2.0 is double speed.

Returns

bool

true if the operation is successful, false otherwise.

SetSpeedAsync(double)

Asynchronously sets the playback speed.

Task<bool> SetSpeedAsync(double speed)

Parameters

speed double

The playback speed.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if successful, false otherwise.

Stop()

Stops playback and resets the media position to the beginning.

void Stop()

StopAsync()

Asynchronously stops playback and resets the media position to the beginning.

Task StopAsync()

Returns

Task

A task that represents the asynchronous operation.

Volume_Get()

Gets the current audio volume level.

double Volume_Get()

Returns

double

The current volume level.

Volume_Set(double)

Sets the audio volume level.

void Volume_Set(double volume)

Parameters

volume double

The volume level, typically from 0.0 (silent) to 1.0 (full volume).