// Copyright (c) Arlo Godfrey. All Rights Reserved. // Licensed under the GNU Lesser General Public License, Version 3.0 with additional terms. // See the LICENSE, LICENSE.LESSER and LICENSE.ADDITIONAL files in the project root for more information. using System; using System.Threading; using System.Threading.Tasks; namespace StrixMusic.Sdk.MediaPlayback { /// /// Basic properties and methods for using and manipulating an audio player. /// /// Play is purposely missing from this interface, and the signature should be defined in a derived type. public interface IAudioPlayerBase { /// /// The amount of time that has passed since a song has started. /// TimeSpan Position { get; } /// PlaybackState PlaybackState { get; } /// /// The volume of the device (0-1). /// double Volume { get; } /// /// The rate of the playback for the current track. /// double PlaybackSpeed { get; } /// /// Seeks the track to a given timestamp. /// /// Time to seek the song to. /// A cancellation token that may be used to cancel the ongoing task. /// A representing the asynchronous operation. Task SeekAsync(TimeSpan position, CancellationToken cancellationToken = default); /// /// Attempts to change the playback speed. /// /// A playback speed between 0 and 1. /// A cancellation token that may be used to cancel the ongoing task. /// A representing the asynchronous operation. Task ChangePlaybackSpeedAsync(double speed, CancellationToken cancellationToken = default); /// /// Resume the device if in the state . /// /// A cancellation token that may be used to cancel the ongoing task. /// A representing the asynchronous operation. Task ResumeAsync(CancellationToken cancellationToken = default); /// /// Pauses the device if in the state /// /// A cancellation token that may be used to cancel the ongoing task. /// A representing the asynchronous operation. Task PauseAsync(CancellationToken cancellationToken = default); /// /// Changes the volume /// /// The volume of the device. /// A cancellation token that may be used to cancel the ongoing task. /// A representing the asynchronous operation. Task ChangeVolumeAsync(double volume, CancellationToken cancellationToken = default); /// /// Fires when changes. /// event EventHandler? PositionChanged; /// /// Fires when changes. /// event EventHandler? PlaybackStateChanged; /// /// Fires when changes. /// event EventHandler? VolumeChanged; /// /// Fires when changes. /// event EventHandler? PlaybackSpeedChanged; } }