Interface ISoundPlayer
Allows to play a sound.
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface ISoundPlayer
Properties
| Improve this Doc View SourceCurrentlyPlayingSounds
Gets a list of currently playing sounds for this audio clip.
Declaration
ReadOnlyCollection<ISound> CurrentlyPlayingSounds { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<ISound> | The list of currently playing sounds. |
IsPlaying
Gets a value indicating whether this ISoundPlayer is playing a sound (or more than 1 sound).
Declaration
bool IsPlaying { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
OnSoundCompleted
An event which is sent when an existing sound has completed playing.
Declaration
IBlockingEvent<ISound> OnSoundCompleted { get; }
Property Value
Type | Description |
---|---|
IBlockingEvent<ISound> | The event. |
OnSoundStarted
An event which is sent when a new sound starts playing.
Declaration
IBlockingEvent<ISound> OnSoundStarted { get; }
Property Value
Type | Description |
---|---|
IBlockingEvent<ISound> | The event. |
Methods
| Improve this Doc View SourcePlay(Boolean, ISoundProperties)
Plays a sound.
Declaration
ISound Play(bool shouldLoop = false, ISoundProperties properties = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | shouldLoop | If set to |
ISoundProperties | properties | Properties. |
Returns
Type | Description |
---|---|
ISound |
Examples
In order to play a sound and then asynchronously wait for it to finish:
private async Task onSpecificTrigger()
{
ISound sound = myAudioClip.Play();
doStuffWhileSoundIsPlaying(); //This happens in parallel to the playing sound
await sound.Completed;
doStuffAfterSoundFinishedPlaying();
}
|
Improve this Doc
View Source
Play(Single, Boolean)
Plays a sound
Declaration
ISound Play(float volume, bool shouldLoop = false)
Parameters
Type | Name | Description |
---|---|---|
System.Single | volume | Volume (allowed values: 0-1, see ISoundPropertie). |
System.Boolean | shouldLoop | If set to |
Returns
Type | Description |
---|---|
ISound |
PlayAndWait(ISoundProperties)
Plays a sound and blocks until the sound is completed.
Declaration
void PlayAndWait(ISoundProperties properties = null)
Parameters
Type | Name | Description |
---|---|---|
ISoundProperties | properties | Properties. |
PlayAndWait(Single)
Plays a sound and blocks until the sound is completed.
Declaration
void PlayAndWait(float volume)
Parameters
Type | Name | Description |
---|---|---|
System.Single | volume | Volume (allowed values: 0-1, see ISoundPropertie). |