Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

WWWAudioExtensions.GetAudioClip fails without error message

Discussion in '2017.1 Beta' started by hybrislabs, Jul 10, 2017.

  1. hybrislabs

    hybrislabs

    Joined:
    Oct 27, 2016
    Posts:
    5
    Hi everyone,

    I'm currently trying to use the function GetAudioClip of the relative new WWWAudioExtensions.
    My Unity Version is 2017.1.0f2 , Windows 10 only

    Below is my code. The WWW request works well and when I try to write the response data to file, the file is ok. But when I try to use the WWW object in GetAudioClip (with stream set to true, because that's what I try to achieve), I get an empty error in my Unity console. The error points to the line where I call GetAudioClip.

    Did anyone use this function with success? What am I missing?

    Thanks for any help!

    Best


    Code (CSharp):
    1.  
    2.  
    3. AudioClip GetClip(string url, byte[] body, Dictionary<string, string> headers) {
    4.  
    5.         WWW www = new WWW(url, body, headers);
    6.         // this line only to test if the request actually works
    7.         // I shouldn't need it as far as I understand
    8.         StartCoroutine(WaitForRequest(www));
    9.  
    10.         // this line fails!
    11.  
    12.         return WWWAudioExtensions(www, false, true, AudioType.OGGVORBIS);
    13.  
    14.     }
    15.  
    16.  
    17.  
    18.     IEnumerator WaitForRequest(WWW www)
    19.  
    20.     {
    21.  
    22.         yield return www;
    23.  
    24.         if (string.IsNullOrEmpty(www.error))
    25.  
    26.         {
    27.  
    28.             Debug.Log("WWW Ok");
    29.             // this is working
    30.            System.IO.FileStream fs = new System.IO.FileStream(@"C:\out.ogg", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
    31.  
    32.             fs.Write(www.bytes, 0, www.bytes.Length);
    33.  
    34.         }
    35.  
    36.         else { Debug.Log("WWW Error")); }
    37.  
    38.     }
     
    Last edited: Jul 10, 2017
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    It is a known bug, streaming audio clip currently does not work. If you set streaming argument to true, it should work fine, of course it means the entire clip has to be downloaded first (isn't that what you do in WaitForRequest()?)

    Note, that GetAudioClip is an extension method, so your call should be:
    Code (CSharp):
    1. return www.GetAudioClip(false, false, AudioType.OGGVORBIS);
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Could you link the corresponding Issue Tracker ticket here, so people can keep an eye on it if interested?