mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-12-13 01:31:49 -05:00
24 lines
646 B
Haxe
24 lines
646 B
Haxe
|
package funkin.util.assets;
|
||
|
|
||
|
import haxe.io.Bytes;
|
||
|
import flixel.system.FlxSound;
|
||
|
|
||
|
class SoundUtil
|
||
|
{
|
||
|
/**
|
||
|
* Convert byte data into a playable sound.
|
||
|
*
|
||
|
* @param input The byte data.
|
||
|
* @return The playable sound, or `null` if loading failed.
|
||
|
*/
|
||
|
public static function buildFlxSoundFromBytes(input:Null<Bytes>):Null<FlxSound>
|
||
|
{
|
||
|
if (input == null) return null;
|
||
|
|
||
|
var openflSound:openfl.media.Sound = new openfl.media.Sound();
|
||
|
openflSound.loadCompressedDataFromByteArray(openfl.utils.ByteArray.fromBytes(input), input.length);
|
||
|
var output:FlxSound = FlxG.sound.load(openflSound, 1.0, false);
|
||
|
return output;
|
||
|
}
|
||
|
}
|