@@ -19,6 +19,9 @@ import openfl.events.Event;
1919import openfl .media .Sound ;
2020import openfl .media .SoundChannel ;
2121import openfl .media .SoundMixer ;
22+ #if lime_vorbis
23+ import lime .media .vorbis .VorbisFile ;
24+ #end
2225
2326/**
2427 * A FlxSound which adds additional functionality:
@@ -342,8 +345,48 @@ class FunkinSound extends FlxSound implements ICloneable<FunkinSound>
342345
343346 if (shouldLoadPartial )
344347 {
345- var music = FunkinSound .loadPartial (pathToUse , params .partialParams ?. start ?? 0.0 , params .partialParams ?. end ?? 1.0 , params ?. startingVolume ?? 1.0 ,
346- params .loop ?? true , false , false , params .onComplete );
348+ var start : Float = params .partialParams ?. start ?? 0.0 ;
349+ var end : Float = params .partialParams ?. end ?? 1.0 ;
350+
351+ // If partial, attempt to load from vorbis first.
352+ #if lime_vorbis
353+ var vorbisSound : Null <Sound > = null ;
354+
355+ var cacheFormat : String = ' $pathToUse .partial- $start - $end ' ;
356+ if (Assets .cache .hasSound (cacheFormat )) vorbisSound = Assets .cache .getSound (cacheFormat );
357+
358+ if (vorbisSound == null )
359+ {
360+ var vorbisFile : Null <VorbisFile > = VorbisFile .fromFile (Paths .stripLibrary (pathToUse ));
361+ if (vorbisFile != null )
362+ {
363+ vorbisSound = Sound .fromAudioBuffer (lime.media. AudioBuffer .fromVorbisFile (vorbisFile ));
364+ Assets .cache .setSound (cacheFormat , vorbisSound );
365+ }
366+ }
367+
368+ if (vorbisSound != null )
369+ {
370+ var sound : Null <FunkinSound > = FunkinSound .load (vorbisSound , params ?. startingVolume ?? 1.0 , params .loop ?? true , false , true , false , params .onComplete );
371+ if (sound != null )
372+ {
373+ sound ._label = pathToUse ;
374+
375+ FlxG .sound .music = sound ;
376+ FlxG .sound .list .remove (FlxG .sound .music );
377+
378+ // Apply the partial limits for the sound.
379+ sound .loopTime = sound .length * start ;
380+ sound .endTime = sound .length * end ;
381+
382+ if (FlxG .sound .music != null && params .onLoad != null ) params .onLoad ();
383+
384+ return true ;
385+ }
386+ }
387+ #end
388+
389+ var music = FunkinSound .loadPartial (pathToUse , start , end , params ?. startingVolume ?? 1.0 , params .loop ?? true , false , false , params .onComplete );
347390
348391 if (music != null )
349392 {
0 commit comments