From 04620e15a8c132a65072f881fa0143e0ccf8d77e Mon Sep 17 00:00:00 2001 From: ACrazyTown <47027981+ACrazyTown@users.noreply.github.com> Date: Fri, 23 May 2025 13:57:51 +0200 Subject: [PATCH] AudioBuffer: Don't force HTML5 audio when using fromBytes()/fromBase64() --- src/lime/media/AudioBuffer.hx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/lime/media/AudioBuffer.hx b/src/lime/media/AudioBuffer.hx index e74b531ec3..8c9ab4bd9b 100644 --- a/src/lime/media/AudioBuffer.hx +++ b/src/lime/media/AudioBuffer.hx @@ -33,10 +33,10 @@ import flash.net.URLRequest; #end /** - The `AudioBuffer` class represents a buffer of audio data that can be played back using an `AudioSource`. + The `AudioBuffer` class represents a buffer of audio data that can be played back using an `AudioSource`. It supports a variety of audio formats and platforms, providing a consistent API for loading and managing audio data. - Depending on the platform, the audio backend may differ, but the class provides a unified interface for accessing + Depending on the platform, the audio backend may differ, but the class provides a unified interface for accessing audio data, whether it's stored in memory, loaded from a file, or streamed. @see lime.media.AudioSource @@ -119,7 +119,13 @@ class AudioBuffer } var audioBuffer = new AudioBuffer(); - audioBuffer.src = new Howl({src: [base64String], html5: true, preload: false}); + + #if force_html5_audio + audioBuffer.src = new Howl({src: [base64String], html5: true, preload: true}); + #else + audioBuffer.src = new Howl({src: [base64String], preload: true}); + #end + return audioBuffer; #elseif (lime_cffi && !macro) #if !cs @@ -165,7 +171,12 @@ class AudioBuffer #if (js && html5 && lime_howlerjs) var audioBuffer = new AudioBuffer(); - audioBuffer.src = new Howl({src: ["data:" + __getCodec(bytes) + ";base64," + Base64.encode(bytes)], html5: true, preload: false}); + + #if force_html5_audio + audioBuffer.src = new Howl({src: ["data:" + __getCodec(bytes) + ";base64," + Base64.encode(bytes)], html5: true, preload: true}); + #else + audioBuffer.src = new Howl({src: ["data:" + __getCodec(bytes) + ";base64," + Base64.encode(bytes)], preload: true}); + #end return audioBuffer; #elseif (lime_cffi && !macro) @@ -287,7 +298,7 @@ class AudioBuffer @return An `AudioBuffer` instance with the decoded audio data. **/ #if lime_vorbis - + public static function fromVorbisFile(vorbisFile:VorbisFile):AudioBuffer { if (vorbisFile == null) return null;