ES3.LoadAudio

public static AudioClip LoadAudio(string audioFilePath, ES3Settings settings)

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

[table th=”0″]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.”[/table]

Returns

The loaded AudioClip.

Examples

C#

// 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

// 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();