FAST SDK Coding Reference 1.0.3
Loading...
Searching...
No Matches
AudioPlayer Class Reference

A class to play AudioClips from a playlist. More...

Public Member Functions

void AddToPlaylist (AudioClip audioClip)
 Add an AudioClip to the end of the playlist.
 
void ClearPlaylist ()
 Remove all the clips from the playlist.
 
void NewPlaylist (AudioClip[] audioClips)
 Change the playlist and stop the player.
 
void Pause ()
 Pauses the AudioPlayer playback by pausing the underlying AudioSource.
 
void Play ()
 Start playing the playlist from the beginning.
 
void Play (AudioClip[] audioClips)
 Change the playlist and start playing it from the beginning.
 
void Stop ()
 Stop playing audio. This does not pause the playlist.
 
void UnPause ()
 Unpauses the AudioPlayer playback by unpausing the underlying AudioSource.
 

Public Attributes

bool isFadeVolumeOnStop = false
 Inspector, Code
Set to true to fade the volume as the AudioPlayer stops.
 
UnityEvent< string > OnClipEnd
 Inspector, Code
Calls the function(s) subscribed to this UnityEvent when an AudioClip reaches the end.
 
UnityEvent< string > OnClipStart
 Inspector, Code
Calls the function(s) subscribed to this UnityEvent when an AudioClip starts playing.
 
UnityEvent< string > OnClipStop
 Inspector, Code
Calls the function(s) subscribed to this UnityEvent when an AudioClip stops playing before it reaches the end.
 
bool[] targetChannels = new bool[2]
 Inspector, Code
The array to select which channels to use. Set an element to true if that index represents a channel to use.
 
float volumeFadeDuration = 0.5f
 Inspector, Code
The volume fade duration in seconds when the AudioPlayer stops if FAST.AudioPlayer.isFadeVolumeOnStop is set to true.
 

Properties

bool IsPaused [get]
 Indicates the AudioPlayer playback is paused if true.
 
bool IsRunning [get]
 Indicates the AudioPlayer is running a play or stop command if true.
 
float MaxVolume [get, set]
 Inspector, Code
The maximum volume of the AudioSources associated with this AudioPlayer.
 
float Progress [get]
 Indicates the amount of the playlist that has been played so far.
 

Private Attributes

List< AudioClip > playlist = new()
 Inspector, Runtime
The list of AudioClips that are playing or queued to play when the AudioPlayer begins playing.
 

Detailed Description

A class to play AudioClips from a playlist.

This class was designed primiarily for narration, but it could be used for any type of audio.

See also
UnityEngine.AudioClip
UnityEngine.AudioSource
UnityEngine.Events.UnityEvent

Member Function Documentation

◆ AddToPlaylist()

void AddToPlaylist ( AudioClip audioClip)

Add an AudioClip to the end of the playlist.

This does not interrupt the AudioPlayer.

Parameters
audioClipThe AudioClip to add to the playlist.

◆ ClearPlaylist()

void ClearPlaylist ( )

Remove all the clips from the playlist.

If an AudioClip is currently playing, it will finish and then the AudioPlayer will stop.

◆ NewPlaylist()

void NewPlaylist ( AudioClip[] audioClips)

Change the playlist and stop the player.

Parameters
audioClipsThe new playlist of AudioClips.

◆ Pause()

void Pause ( )

Pauses the AudioPlayer playback by pausing the underlying AudioSource.

◆ Play() [1/2]

void Play ( )

Start playing the playlist from the beginning.

If the AudioPlayer is already playing, it will restart the playlist.

◆ Play() [2/2]

void Play ( AudioClip[] audioClips)

Change the playlist and start playing it from the beginning.

If the AudioPlayer is already playing, it will restart the playlist.

Parameters
audioClipsThe new playlist of AudioClips.

◆ Stop()

void Stop ( )

Stop playing audio. This does not pause the playlist.

If you play after calling Stop(), the playlist will restart from the beginning.

◆ UnPause()

void UnPause ( )

Unpauses the AudioPlayer playback by unpausing the underlying AudioSource.

Member Data Documentation

◆ isFadeVolumeOnStop

bool isFadeVolumeOnStop = false

Inspector, Code
Set to true to fade the volume as the AudioPlayer stops.

◆ OnClipEnd

UnityEvent<string> OnClipEnd

Inspector, Code
Calls the function(s) subscribed to this UnityEvent when an AudioClip reaches the end.

The string parameter passed into the callback function(s) is the name of the AudioClip that reached the end.

◆ OnClipStart

UnityEvent<string> OnClipStart

Inspector, Code
Calls the function(s) subscribed to this UnityEvent when an AudioClip starts playing.

The string parameter passed into the callback function(s) is the name of the AudioClip that started playing.

◆ OnClipStop

UnityEvent<string> OnClipStop

Inspector, Code
Calls the function(s) subscribed to this UnityEvent when an AudioClip stops playing before it reaches the end.

The string parameter passed into the callback function(s) is the name of the AudioClip that stopped playing.

◆ playlist

List<AudioClip> playlist = new()
private

Inspector, Runtime
The list of AudioClips that are playing or queued to play when the AudioPlayer begins playing.

This attribute is primarily to make the playlist visible in the Inspector at runtime. Use the AudioPlayer functions to modify the playlist.

◆ targetChannels

bool [] targetChannels = new bool[2]

Inspector, Code
The array to select which channels to use. Set an element to true if that index represents a channel to use.

Most commonly, set the array size to the number of audio channels used in the application.

◆ volumeFadeDuration

float volumeFadeDuration = 0.5f

Inspector, Code
The volume fade duration in seconds when the AudioPlayer stops if FAST.AudioPlayer.isFadeVolumeOnStop is set to true.

Property Documentation

◆ IsPaused

bool IsPaused
get

Indicates the AudioPlayer playback is paused if true.

◆ IsRunning

bool IsRunning
get

Indicates the AudioPlayer is running a play or stop command if true.

◆ MaxVolume

float MaxVolume
getset

Inspector, Code
The maximum volume of the AudioSources associated with this AudioPlayer.

The volume range is clamped to [0.0, 1.0]

◆ Progress

float Progress
get

Indicates the amount of the playlist that has been played so far.

The progress range is normalized to [0.0, 1.0]


The documentation for this class was generated from the following file: