IAudioPlayer
The interface of the AudioPlayer, it's the main entry of the Method Chaining
Last updated
The interface of the AudioPlayer, it's the main entry of the Method Chaining
Last updated
NameSpace | Accessibility |
---|---|
When BroAudio.Play(id) is called, it returns an IAudioPlayer representing the AudioPlayer currently playing the audio. You can chain more methods after this, or cache the instance for later use.
This interface is composed of several interfaces, including IAudioStoppable, IVolumeSettable, IEffectDecoratable, IMusicDecoratable.
The AudioPlayer has utilized the ObjectPool design, which will recycle the AudioPlayer to the pool once it has finished its playing (or being stopped manually).
If you've cached the instance of the AudioPlayer and tried to access it after it finished (recycled). To avoid accessing the wrong player, Bro will reject your access and log a warning to indicate the target player is unavailable.
Property | Type | Description |
---|---|---|
Method | Return | Parameters | Description |
---|---|---|---|
Method | Return | Parameters | Description |
---|---|---|---|
Method | Return | Parameters | Description |
---|---|---|---|
Method | Return | Parameters | Description |
---|---|---|---|
Method | Return | Parameters | Description |
---|---|---|---|
Method | Return | Parameters | Description |
---|---|---|---|
Ami.BroAudio
public
ID
SoundID, int
The SoundID that the player is playing
IsPlaying
bool
Return true if the player's AudioSource is playing
IsActive
bool
Returns true if the player is about to play or is playing
AudioSource
Gets the AudioSource component of the player
OnEndPlaying deprecated <use OnEnd instead>
event Action<SoundID>
Triggered when the audio player has finished playing
GetOutputData
void
float[] samples, int channels
Similar to AudioSource.GetOutputData, It's recommended to use this in OnUpdate
GetSpectrumData
void
float[] samples, int channels, FFTWindow window
Similar toAudioSource.GetSpectrumData, It's recommended to use this in OnUpdate
SetPitch
IAudioPlayer
float pitch
Set the player's pitch.
IAudioPlayer
float pitch, float fadeTime
Set the player's pitch by the given fade time
SetVelocity
IAudioPlayer
int velocity
Set the velocity to determine which audio clip to play
OnStart
IAudioPlayer
Action<IAudioPlayer>
Triggered when the AudioPlayer starts playing
OnUpdate
IAudioPlayer
Action<IAudioPlayer>
Triggered each frame while the AudioPlayer is playing
OnEnd
IAudioPlayer
Action<IAudioPlayer>
Triggered when the AudioPlayer stops playing
OnAudioFilterRead
IAudioPlayer
Action<float[], int>
Similar to MonoBehaviour.OnAudioFilterRead().
Stop
void
none
Stop playing the audio
void
Action onFinished
Stop playing and trigger the action when it's finished
void
float fadeOut
Stop playing the audio by the given fadeOut time
void
Action onFinished, float fadeOut
Stop playing the audio by the given fadeOut time, and trigger the action when it's finished
Pause
void
none
Pause the audio
void
float fadeOut
Pause by the given fadeOut time
UnPause
void
none
Resume the paused audio
void
float fadeIn
Resume the paused audio by the given fadeIn time
SetVolume
IAudioPlayer
float volume
Set the player's volume (acceptable range 0~10)
void
float volume, float fadeTime
Set the player's volume by the given fadeTime
AsBGM
none
Set the player as a music player, which will transition automatically if another BGM is played after it
AsDominator
none
Set the player as a dominator player, which will affect or change the behavior of other audio players during its playback