Class MusicPlayer
A Singleton audio player that can crossfade songs.
Inheritance
Object
Component
Behaviour
MonoBehaviour
MusicPlayer
Inherited Members
Namespace: GGL.Audio.Player
Assembly: GGL.dll
Syntax
[AddComponentMenu("GG-Library/Singletons/Audio/Music Player")]
[HelpURL("https://ggl.yoannhaffner.com/articles/audio.html#optimisation")]
public class MusicPlayer : AbstractPlayer<MusicPlayer>
Fields
| Edit this page View Sourceplayer2
Declaration
[SerializeField]
protected AudioSource player2
Field Value
Type | Description |
---|---|
AudioSource | A Second audio player used for crossfade transition |
Methods
| Edit this page View SourcePlay(AudioClip, float, float)
Play an audio file on the Singleton audio player with a cross-fading.
Declaration
public static void Play(AudioClip clip, float volume, float crossFade)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | Audio file to play. |
float | volume | Volume in range [0;1]. |
float | crossFade | Cross-fading duration in seconds. |
PlayClip(AudioClip, float)
Play an audio file on the Singleton audio player with a 200ms default cross-fading (it sounds nice :3) .
Declaration
protected override void PlayClip(AudioClip clip, float volume = 1)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | Audio file to play. |
float | volume | Volume in range [0;1]. |
Overrides
| Edit this page View SourceStop(float)
Stop whatever is being played... with a fading.
Declaration
public static void Stop(float fading)
Parameters
Type | Name | Description |
---|---|---|
float | fading |
StopClip()
Stop whatever is being played with a 200ms default fading.
Declaration
protected override void StopClip()