ES3.LoadAudio
Description
Loads an audio file as an AudioClip.
MP3 files are only supported on mobile, and Ogg Vorbis files are only supported on standalone platforms.
WAV, XM, IT, MOD and S3M files are supported on all platforms except WebGL.
As this method requires file access, this method is not supported on WebGL.
A FileNotFoundException will be thrown if the file does not exist. In this case, you can use ES3.FileExists to check if the data exists before loading.
Parameters
audiofilePath | The relative or absolute path of the audio file we want to load. |
settings |
[Optional] The settings we want to use to override the default settings. |
Returns
The loaded AudioClip.
Examples
C#
1 2 3 4 5 6 |
// Get the AudioSource we want to use to play our AudioClip. var source = this.GetComponent<AudioSource>(); // Load an AudioClip from the streaming assets folder into our source. source.clip = ES3.LoadAudio(Application.streamingAssetsPath + "/AudioFile.wav"); // Play the AudioClip we just loaded using our AudioSource. source.Play(); |
JS
1 2 3 4 5 6 |
// Get the AudioSource we want to use to play our AudioClip. var source = this.GetComponent.<AudioSource>(); // Load an AudioClip from the streaming assets folder into our source. source.clip = ES3.LoadAudio(Application.streamingAssetsPath + "/AudioFile.wav"); // Play the AudioClip we just loaded using our AudioSource. source.Play(); |