Represents a audio resource that can be played, paused, resumed, and disposed.
More...
|
| void | Play (bool fromStart=true) |
| | Starts playback of the audio stream.
|
| void | Pause () |
| | Pauses playback if it is currently active.
|
| void | Resume () |
| | Resumes playback if the output device is currently paused.
|
| void | Seek (TimeSpan position) |
| | Seeks to the specified position within the audio stream.
|
| void | Stop () |
| | Stops the output device, halting any ongoing audio playback.
|
| void | Dispose () |
| | Releases all resources used by the AudioResource instance.
|
|
| Func< Task >? | PlaybackCompletedAsync |
| | Asynchronous callback that is invoked when playback completes. Will not be invoked if the audio is looping.
|
|
| virtual void | Dispose (bool disposing) |
| | Releases the unmanaged resources used by the AudioResource and optionally releases the managed resources.
|
|
| string | Key [get] |
| | Gets the unique key associated with this audio resource.
|
| byte?[] | OriginalBytes [get] |
| | Gets the original byte array of the audio data, if available.
|
| string? | SourceFilePath [get] |
| | Original file path when the sound was loaded from disk (loose file). Null when loaded from an AssetsFile.
|
| AssetsFileIdentifier? | AssetIdentifier [get] |
| | Asset identifier when the sound was loaded from an AssetsFile. Null when loaded from a loose file.
|
| string? | SourceExtension [get] |
| | Normalized file extension (".wav", ".mp3", etc) used to select the reader.
|
| string? | TempFilePath [get] |
| | Gets or sets the temporary file path used for WaveReaders that require a file on disk.
|
| bool | IsPaused [get] |
| | Gets a value indicating whether the playback is currently paused.
|
| bool | IsPlaying [get] |
| | Gets a value indicating whether audio playback is currently active.
|
| PlaybackState | State [get] |
| | Gets the current playback state of the output device.
|
| TimeSpan | CurrentTime [get, set] |
| | Gets or sets the current playback position within the audio stream.
|
| TimeSpan | Duration [get] |
| | Gets the total duration of the audio represented by the wave stream.
|
| bool | IsLooping [get, set] |
| | Gets or sets a value indicating whether the playback is set to loop.
|
| float | Volume [get, set] |
| | Gets or sets the volume of the audio output. 0.0 is silent, 1.0 is full volume.
|
| float | Pan [get, set] |
| | Gets or sets the stereo pan position of the audio output. -1 is full left, 0 is center, and 1 is full right.
|
|
| EventHandler | PlaybackCompleted |
| | Event that is raised when playback completes. Will not be raised if the audio is looping.
|
| EventHandler | Disposed |
| | Event that is raised when the audio resource is disposed.
|
Represents a audio resource that can be played, paused, resumed, and disposed.
◆ Dispose() [1/2]
| void Gondwana.Audio.AudioResource.Dispose |
( |
| ) |
|
Releases all resources used by the AudioResource instance.
This method stops playback, disposes of the output device and wave stream, deletes any temporary files, and raises the Disposed event. After calling this method, the instance should not be used further.
◆ Dispose() [2/2]
| virtual void Gondwana.Audio.AudioResource.Dispose |
( |
bool | disposing | ) |
|
|
protectedvirtual |
Releases the unmanaged resources used by the AudioResource and optionally releases the managed resources.
This method implements the dispose pattern. When disposing is true, it releases both managed and unmanaged resources. When false, it releases only unmanaged resources.
- Parameters
-
| disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
◆ Pause()
| void Gondwana.Audio.AudioResource.Pause |
( |
| ) |
|
Pauses playback if it is currently active.
This method pauses the playback only if it is currently in progress. If playback is already paused or not started, calling this method has no effect.
◆ Play()
| void Gondwana.Audio.AudioResource.Play |
( |
bool | fromStart = true | ) |
|
Starts playback of the audio stream.
If the audio is already playing, calling this method has no effect. Ensure the audio stream is properly initialized before invoking this method.
- Parameters
-
| fromStart | A value indicating whether playback should start from the beginning of the audio stream. true to start from the beginning; otherwise, playback resumes from the current position. |
◆ Resume()
| void Gondwana.Audio.AudioResource.Resume |
( |
| ) |
|
Resumes playback if the output device is currently paused.
This method has no effect if the output device is not paused. Ensure that the output device is properly initialized and in a paused state before calling this method.
◆ Seek()
| void Gondwana.Audio.AudioResource.Seek |
( |
TimeSpan | position | ) |
|
Seeks to the specified position within the audio stream.
If the audio is currently playing, it will be paused during the seek operation and resumed afterward.
- Parameters
-
| position | The position to seek to, specified as a TimeSpan. If the value is less than TimeSpan.Zero, the position is set to the start of the stream. If the value exceeds the total duration of the stream, the position is set to the end of the stream. |
◆ Stop()
| void Gondwana.Audio.AudioResource.Stop |
( |
| ) |
|
Stops the output device, halting any ongoing audio playback.
◆ PlaybackCompletedAsync
| Func<Task>? Gondwana.Audio.AudioResource.PlaybackCompletedAsync |
Asynchronous callback that is invoked when playback completes. Will not be invoked if the audio is looping.
◆ AssetIdentifier
Asset identifier when the sound was loaded from an AssetsFile. Null when loaded from a loose file.
◆ CurrentTime
| TimeSpan Gondwana.Audio.AudioResource.CurrentTime |
|
getset |
Gets or sets the current playback position within the audio stream.
◆ Duration
| TimeSpan Gondwana.Audio.AudioResource.Duration |
|
get |
Gets the total duration of the audio represented by the wave stream.
◆ IsLooping
| bool Gondwana.Audio.AudioResource.IsLooping |
|
getset |
Gets or sets a value indicating whether the playback is set to loop.
◆ IsPaused
| bool Gondwana.Audio.AudioResource.IsPaused |
|
get |
Gets a value indicating whether the playback is currently paused.
◆ IsPlaying
| bool Gondwana.Audio.AudioResource.IsPlaying |
|
get |
Gets a value indicating whether audio playback is currently active.
◆ Key
| string Gondwana.Audio.AudioResource.Key |
|
get |
Gets the unique key associated with this audio resource.
◆ OriginalBytes
| byte? [] Gondwana.Audio.AudioResource.OriginalBytes |
|
get |
Gets the original byte array of the audio data, if available.
◆ Pan
| float Gondwana.Audio.AudioResource.Pan |
|
getset |
Gets or sets the stereo pan position of the audio output. -1 is full left, 0 is center, and 1 is full right.
◆ SourceExtension
| string? Gondwana.Audio.AudioResource.SourceExtension |
|
get |
Normalized file extension (".wav", ".mp3", etc) used to select the reader.
◆ SourceFilePath
| string? Gondwana.Audio.AudioResource.SourceFilePath |
|
get |
Original file path when the sound was loaded from disk (loose file). Null when loaded from an AssetsFile.
◆ State
| PlaybackState Gondwana.Audio.AudioResource.State |
|
get |
Gets the current playback state of the output device.
◆ TempFilePath
| string? Gondwana.Audio.AudioResource.TempFilePath |
|
get |
Gets or sets the temporary file path used for WaveReaders that require a file on disk.
◆ Volume
| float Gondwana.Audio.AudioResource.Volume |
|
getset |
Gets or sets the volume of the audio output. 0.0 is silent, 1.0 is full volume.
◆ Disposed
| EventHandler Gondwana.Audio.AudioResource.Disposed |
Event that is raised when the audio resource is disposed.
◆ PlaybackCompleted
| EventHandler Gondwana.Audio.AudioResource.PlaybackCompleted |
Event that is raised when playback completes. Will not be raised if the audio is looping.