Music Player
Assembly: CarterGames.AudioManager.Runtime
Namespace: CarterGames.Assets.AudioManager
Actions
OnTrackStarted
Action
Triggered whenever a new track is started on a track loops around to the start again.
OnTrackEnded
Action
Triggered whenever the track has ended.
OnTrackLooped
Action
Triggered whenever a track loops around back to the start.
OnTrackChanged
Action
Triggered whenever the user changes the active track.
OnTrackTransitionComplete
Action
Triggered whenever the active track transition has completed.
Properties
IsTrackPlaying
Property
Returns
bool
Gets whether or not there is a track currently playing?
GetActiveTrack
Property
Returns
AudioClip
Gets the track that is currently being player by the music player script.
GetTrackPosition
Property
Returns
float
Gets the current time in seconds that the track is at.
GetActiveSource
Property
Returns
AudioSource
Gets the audio source component that is playing the active track.
ShouldLoop
Property
Gets/Sets whether or not the active track should loop.
Methods
SetVolume
Method
Declaration
MusicPlayer.SetVolume(float value);
Parameters
float
→ The volume to set between 0-1.
Sets the volume of the music player to the entered value. Range is between 0-1.
MusicPlayer.SetVolume(.75f);
StopTrack
Method
Declaration
MusicPlayer.StopTrack();
Stops the active track from playing without any transition.
MusicPlayer.StopTrack();
PlayTrack
Method
Declarations
MusicPlayer.instance.PlayTrack(AudioClip track)
MusicPlayer.instance.PlayTrack(AudioClip track, TransitionType transitionType)
MusicPlayer.instance.PlayTrack(AudioClip track, TransitionType transitionType, float transitionDuration)
MusicPlayer.instance.PlayTrack(AudioClip track, float startTime)
MusicPlayer.instance.PlayTrack(AudioClip track, float startTime, TransitionType transitionType)
MusicPlayer.instance.PlayTrack(AudioClip track, float startTime, TransitionType transitionType, float transitionDuration)
MusicPlayer.instance.PlayTrack(AudioClip track, float startTime, float endTime)
MusicPlayer.instance.PlayTrack(AudioClip track, float startTime, float endTime, TransitionType transitionType)
MusicPlayer.instance.PlayTrack(AudioClip track, float startTime, float endTime, TransitionType transitionType, float transitionDuration)
Parameters
AudioClip
→ The track that you wish to play. Use null if you want to just end the current track without changing to a new one.
TransitionType
→ The type of transition the music player should use when changing the track.
float
→ Start Time → The time when the track should start playing from. Time is in seconds.
float
→ End Time → The time when the track should end/loop from. Time is in seconds.
float
→ Transition Duration → The amount of time the transition should take to complete. Default is 1 second.
Plays the track requested on the music player script. There are several overloads for this method that allow for additional options. If just using the audioclip param the transition will stay as the last one used in the inspector, the start time will be set to 0 and the end time will be set to the track length.
AudioManager.instance.Play("MyClip");
AudioManager.instance.Play("MyClip", mixer);
AudioManager.instance.Play("MyClip", mixerID);
AudioManager.instance.Play("MyClip", args);