Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.utilities.rest 2.5.1 #67

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
com.utilities.rest 2.5.1
- added compressed and streamingAudio flags to Rest.DownloadAudioClipAsync
  • Loading branch information
StephenHodgson committed Jan 28, 2024
commit ca937b6f7fc8abb9636dca4e61cb5334fbdea995
13 changes: 11 additions & 2 deletions Utilities.Rest/Packages/com.utilities.rest/Runtime/Rest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ public static async Task<Texture2D> DownloadTextureAsync(
/// <param name="httpMethod">Optional, must be either GET or POST.</param>
/// <param name="jsonData">Optional, json payload. Only <see cref="jsonData"/> OR <see cref="payload"/> can be supplied.</param>
/// <param name="payload">Optional, raw byte payload. Only <see cref="payload"/> OR <see cref="jsonData"/> can be supplied.</param>
/// <param name="compressed">Optional, Create AudioClip that is compressed in memory.<br/>
/// Note: When <see cref="streamingAudio"/> is true, it supersedes compression, and the download handler creates an AudioClip similar
/// to an imported clip with the loadType AudioClipLoadType.Streaming.
/// </param>
/// <param name="streamingAudio">Optional, Create a streaming audio clip.</param>
/// <param name="parameters">Optional, <see cref="RestParameters"/>.</param>
/// <param name="cancellationToken">Optional, <see cref="CancellationToken"/>.</param>
/// <returns>A new <see cref="AudioClip"/> instance.</returns>
Expand All @@ -593,6 +598,8 @@ public static async Task<AudioClip> DownloadAudioClipAsync(
string fileName = null,
string jsonData = null,
byte[] payload = null,
bool compressed = false,
bool streamingAudio = false,
RestParameters parameters = null,
CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -624,6 +631,8 @@ public static async Task<AudioClip> DownloadAudioClipAsync(

UploadHandler uploadHandler = null;
using var downloadHandler = new DownloadHandlerAudioClip(url, audioType);
downloadHandler.compressed = compressed;
downloadHandler.streamAudio = streamingAudio;

if (httpMethod == UnityWebRequest.kHttpVerbPOST)
{
Expand All @@ -634,7 +643,7 @@ public static async Task<AudioClip> DownloadAudioClipAsync(
throw new ArgumentException($"{nameof(payload)} and {nameof(jsonData)} cannot be supplied in the same request. Choose either one or the other.", nameof(jsonData));
}

payload = new UTF8Encoding().GetBytes(jsonData);
payload = new UTF8Encoding().GetBytes(jsonData!);

var jsonHeaders = new Dictionary<string, string>
{
Expand Down Expand Up @@ -737,7 +746,7 @@ public static async Task<AudioClip> StreamAudioAsync(
throw new ArgumentException($"{nameof(payload)} and {nameof(jsonData)} cannot be supplied in the same request. Choose either one or the other.", nameof(jsonData));
}

payload = new UTF8Encoding().GetBytes(jsonData);
payload = new UTF8Encoding().GetBytes(jsonData!);

var jsonHeaders = new Dictionary<string, string>
{
Expand Down
2 changes: 1 addition & 1 deletion Utilities.Rest/Packages/com.utilities.rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Utilities.Rest",
"description": "This package contains useful RESTful utilities for the Unity Game Engine.",
"keywords": [],
"version": "2.5.0",
"version": "2.5.1",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest/releases",
Expand Down
2 changes: 1 addition & 1 deletion Utilities.Rest/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"com.unity.addressables": "1.21.19",
"com.unity.ide.rider": "3.0.27",
"com.unity.ide.visualstudio": "2.0.22",
"com.utilities.buildpipeline": "1.1.9"
"com.utilities.buildpipeline": "1.2.1"
},
"scopedRegistries": [
{
Expand Down