2023-08-31 05:56:35 +00:00
|
|
|
package funkin.audio;
|
|
|
|
|
|
|
|
import flash.media.Sound;
|
|
|
|
import flixel.sound.FlxSound;
|
|
|
|
import flixel.system.FlxAssets.FlxSoundAsset;
|
|
|
|
import openfl.Assets;
|
|
|
|
#if (openfl >= "8.0.0")
|
|
|
|
import openfl.utils.AssetType;
|
|
|
|
#end
|
|
|
|
|
|
|
|
/**
|
|
|
|
* a FlxSound that just overrides loadEmbedded to allow for "streamed" sounds to load with better performance!
|
|
|
|
*/
|
2025-04-15 15:12:14 +00:00
|
|
|
@:nullSafety
|
2023-08-31 05:56:35 +00:00
|
|
|
class FlxStreamSound extends FlxSound
|
|
|
|
{
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2025-04-15 15:12:14 +00:00
|
|
|
override public function loadEmbedded(EmbeddedSound:Null<FlxSoundAsset>, Looped:Bool = false, AutoDestroy:Bool = false, ?OnComplete:Void->Void):FlxSound
|
2023-08-31 05:56:35 +00:00
|
|
|
{
|
|
|
|
if (EmbeddedSound == null) return this;
|
|
|
|
|
|
|
|
cleanup(true);
|
|
|
|
|
|
|
|
if ((EmbeddedSound is Sound))
|
|
|
|
{
|
|
|
|
_sound = EmbeddedSound;
|
|
|
|
}
|
|
|
|
else if ((EmbeddedSound is Class))
|
|
|
|
{
|
|
|
|
_sound = Type.createInstance(EmbeddedSound, []);
|
|
|
|
}
|
|
|
|
else if ((EmbeddedSound is String))
|
|
|
|
{
|
|
|
|
if (Assets.exists(EmbeddedSound, AssetType.SOUND)
|
|
|
|
|| Assets.exists(EmbeddedSound, AssetType.MUSIC)) _sound = Assets.getMusic(EmbeddedSound);
|
|
|
|
else
|
|
|
|
FlxG.log.error('Could not find a Sound asset with an ID of \'$EmbeddedSound\'.');
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: can't pull ID3 info from embedded sound currently
|
|
|
|
return init(Looped, AutoDestroy, OnComplete);
|
|
|
|
}
|
|
|
|
}
|