I’m working on a project that let users record an audio clip, and upload it on web sharing with other users. But I can’t use GetAudioClip() to make the file already on web downloaded and listened.
Now I’m doing the project on Mac, and the project is going to run on mobile device. Database is set in localhost testing for now. here’s the part of code that downloading and playing the wav file on web.
I’ve searched and tried many solutions. But it never work. How to use GetAudioClip() or is there anything wrong in code?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class audioListener : MonoBehaviour {
string theURL = "http://localhost/test/uploaded file/audio20178179491.wav";
AudioSource aud;
AudioClip clip;
void Start () {
}
void Update () {
if (Input.GetKeyDown (KeyCode.L)) {
StartCoroutine (DownloadAudio ());
}
}
IEnumerator DownloadAudio(){
WWW www = new WWW (theURL);
Debug.Log ("loading...");
yield return www;
Debug.Log ("done.");
clip = www.GetAudioClipCompressed(true, AudioType.WAV);
GameObject Obj = GameObject.Find ("Audio");
aud = Obj.GetComponent<AudioSource> ();
aud.clip = clip;
aud.Play ();
}
}
Please help me…
Thanks.