DownloadHandlerAudioClip
A DownloadHandler subclass specialized for downloading audio data for use as AudioClip objects.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Class
- Namespace: UnityEngine.Networking
- Assembly: UnityEngine.UnityWebRequestAudioModule
- Inherits from: DownloadHandler
- Implements: IDisposable
public sealed class DownloadHandlerAudioClip : DownloadHandler, IDisposable
Remarks
DownloadHandlerAudioClip stores received data in a pre-allocated Unity AudioClip object. It is optimized for downloading audio data from Web servers, and may perform audio data decompression and decoding on a worker thread.
For use cases where you wish to download an audio clip via HTTP and use it as an AudioClip within Unity, usage of this class is strongly recommended.
Examples
using System.Collections;using UnityEngine;using UnityEngine.Networking;public class AudioDownloader : MonoBehaviour { void Start () { StartCoroutine(GetAudioClip()); } IEnumerator GetAudioClip() { using (var uwr = UnityWebRequestMultimedia.GetAudioClip("https://myserver.com/mysound.ogg", AudioType.OGGVORBIS)) { yield return uwr.SendWebRequest(); if (uwr.result != UnityWebRequest.Result.Success) { Debug.LogError(uwr.error); yield break; } AudioClip clip = DownloadHandlerAudioClip.GetContent(uwr); // use audio clip } }}
Constructors
Constructor | Description |
|---|---|
| DownloadHandlerAudioClip(System.String,UnityEngine.AudioType) | Constructor, specifies what kind of audio data is going to be downloaded. |
| DownloadHandlerAudioClip(System.String,UnityEngine.AudioType,System.Boolean) | Constructor, specifies what kind of audio data is going to be downloaded. |
| DownloadHandlerAudioClip(System.Uri,UnityEngine.AudioType) | Constructor, specifies what kind of audio data is going to be downloaded. |
| DownloadHandlerAudioClip(System.Uri,UnityEngine.AudioType,System.Boolean) | Constructor, specifies what kind of audio data is going to be downloaded. |
Properties
Property | Description |
|---|---|
| ambisonic | Whether the downloaded AudioClip is marked as ambisonic. |
| audioClip | Returns the downloaded AudioClip, or |
| compressed | Create that is compressed in memory. |
| streamAudio | Create streaming AudioClip. |
Static Methods
Method | Description |
|---|---|
| GetContent | Returns the downloaded AudioClip, or |