Importing a file - Hello-Meow/AudioImporter GitHub Wiki

To import a song, we need an AudioImporter component. We can add NAudioImporter (or MobileImporter for Android or iOS) to a GameObject and start using it.

To start importing a file, use AudioImporter.Import(). This will start loading the file into an AudioClip. This happens in the background as much as possible. Use the AudioImporter.Loaded event to obtain the audioclip. Alternatively you can use AudioImporter.isDone or AudioImporter.progress to find out when the AudioClip is available.

using UnityEngine;

public class ImporterExample : MonoBehaviour 
{
    public string path;
    public AudioImporter importer;
    public AudioSource audioSource;

    void Awake()
    {                
        importer.Loaded += OnLoaded;
        importer.Import(path);
    }

    private void OnLoaded(AudioClip clip)
    {
        audioSource.clip = clip;
        audioSource.Play();
    }
}