I am currently pulling a .wav file from an API. I would like to play it at run-time. Currently I need to save the .wav file to the persistentDataPath and then use the WWW class to load an audio clip using the file:// prefix. It works fine but the docs do mention that the WWW class is obsolete. What other options do I have if I want to avoid the obsolete method group?

I don't need to save the file to disk, I am simply doing that at the moment because its fairly safe to save it and then read it back out.

  • \$\begingroup\$ Which version unity? unitywebrequest has been around a while \$\endgroup\$
    – BugFinder
    Apr 8 '19 at 11:42
  • \$\begingroup\$ Did you follow the second link on that page, where it says "The UnityWebRequestWWW module implements the legacy WWW lets you communicate with http services. It is recommended to use UnityWebRequest directly for new code."? \$\endgroup\$
    – DMGregory
    Apr 8 '19 at 11:52
  • \$\begingroup\$ @DMGregory UnityWebRequest has no methods to load AudioClip data at run-time, nor does it provide any examples for loading a file from disk. Care to elaborate on how that would work? \$\endgroup\$
    – Scott
    Apr 9 '19 at 2:13
  • \$\begingroup\$ @DMGregory I'll have a look at that over the weekend. As I already have the file in memory from a HttpClient call (I need to use this sadly) I might not be able to use a UnityWebRequest but I might be able to use a download handler to pull out the resulting file anyway. Cheers. \$\endgroup\$
    – Scott
    Apr 11 '19 at 1:57

You must log in to answer this question.

Browse other questions tagged .