Search Unity

UnityWebRequest get audio clip using post data

Discussion in 'Scripting' started by NathanWarden, Mar 14, 2019 at 4:34 PM.

  1. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    660
    Hello,

    I've been converting my WWW code over to UnityWebRequest and think I've run into a bit of a snag. The way we get audio clips from our server with our api is via POST data, but UnityWebRequestMultimedia doesn't seem to offer a way to submit post data. Is there another way to do this or am I missing something?

    We're using 2017.4

    Thanks!
    Nathan
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    2,012
    Simplest way would be to do UnityWebRequest.Post() and then create and assign DownloadHandlerAudioClip to downloadHandler property. Small penalty of creating and discarding DownloadHandlerBuffer.
    To avoid it you'd have to lower level. If you are willing to go that path, find relevant Post implementation in our C# reference code and replace the DownloadHandlerBuffer with DownloadHandlerAudioClip:
    https://github.com/Unity-Technologi...nityWebRequest/Public/WebRequestExtensions.cs