Using www.audioClip

I never heard of this feature until today. I discovered this:

WWW.audioClip

This is a really interesting page and I still don’t get it how it works after 1 hour and like 30 min. trying :frowning:

That’s for downloading audio off the internet. Do you know how WWW works? If you know that, then it’ll be pretty obvious how to use the audio clip property specifically.

Well, I could use some help when it comes to WWW. I used images (down)loading and going into Unity3D, and it worked correctly.
But when you read the article/page above, you’ll see that just a few formats are supported. I literally tried almost every format but it didn’t seem to work. The audiofile of mine contains 22kb only, mp3 file format.

Thanks for reading.
As I said: I could really use some help. :frowning:

If you have a question, you should ask it and be specific. Attach the relevant code you’re using and be clear about what the trouble is and what you are unable to figure out on your own.

Ok, more specific then.

        var url : String;
    var source: AudioSource;
  
    function Start () {
        var www = new WWW(url);
        source = GetComponent.<AudioSource>();
        source.clip = www.audioClip;
    }

    function Update () {
        if(!source.isPlaying && source.clip.isReadyToPlay)
            source.Play();
    }

I’m having trouble with the script (see above).
I created an empty scene, with default Main Camera, and an empty Gameobject with that script attached.

The Gameobject has also an AudioSource and the volume is fine, but using this script with the following url (for the www-audioclip) :
www.wavsource.com/snds_2015-07-19_1628654123857389/sfx/ocean2.wav

Doesn’t seem to work. Silence, that’s all I can hear. :frowning:

Maybe you should check if its working step by step.
Check if the download of the file is working or not.

        if (!string.IsNullOrEmpty(www.error))
            Debug.Log(www.error);

If you get a console log you have a problem with the download.
Do you get any error or warnings or its just not playing?