IAudioPlayer
The interface of the AudioPlayer, it's the main entry of the Method Chaining
Ami.BroAudio
public
Description
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.
Properties
ID
SoundID, int
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
Triggered when the audio player has finished playing
Public Methods
GetOutputData
void
float[] samples, int channels
GetSpectrumData
void
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
Event Messages
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>
IAudioStoppable
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
IVolumeSettable
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
IMusicDecoratable
AsBGM
none
Set the player as a music player, which will transition automatically if another BGM is played after it
IEffectDecoratable
AsDominator
none
Set the player as a dominator player, which will affect or change the behavior of other audio players during its playback
Last updated