I’ve dowloaded a bunch of audiofiles (.mp3) to my persistentDataPath. Now I want to load them to memory from the persistentDataPath and push each of hem inside an array. Dont know how to load them.
thanks in advance.
I’ve dowloaded a bunch of audiofiles (.mp3) to my persistentDataPath. Now I want to load them to memory from the persistentDataPath and push each of hem inside an array. Dont know how to load them.
thanks in advance.
I know it’s an old question, but here’s a solution anyways.
You can use WWW to load the audio files. You should take a look at WWW.GetAudioClip() Unity - Scripting API: WWW.GetAudioClip
Here’s how it can be used:
using UnityEngine;
using System.Collections;
using System.IO;
public class LoadFromPersistant : MonoBehaviour {
private AudioSource auSource;
public AudioClip clip;
void Start()
{
auSource = GetComponent<AudioSource>();
StartCoroutine("LoadClip");
}
IEnumerator LoadClip()
{
string path = "file:" + Application.persistentDataPath + "/Town_Ambience.wav";
WWW www = new WWW(path);
yield return www;
clip = www.GetAudioClip(false, false, AudioType.WAV);
auSource.clip = clip;
auSource.Play();
}
}