diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 736f1d6b..7dcb6f3d 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -246,24 +246,37 @@ class FreeplayState extends MusicBeatState autoplayElapsed += elapsed; if (!disableAutoPlay && !songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]))) { - var huh:Void->Void = function() { - var soundPath = curPlayingInst; - var sound = null; - if (Assets.exists(soundPath, SOUND) || Assets.exists(soundPath, MUSIC)) - sound = Assets.getSound(soundPath); - else - FlxG.log.error('Could not find a Sound asset with an ID of \'$soundPath\'.'); + var streamed = false; + if (Options.streamedMusic) { + var sound = Assets.getMusic(curPlayingInst, true, false); + streamed = sound != null; - if (sound != null && autoplayShouldPlay) { + if (streamed && autoplayShouldPlay) { FlxG.sound.playMusic(sound, 0); Conductor.changeBPM(songs[curSelected].bpm, songs[curSelected].beatsPerMeasure, songs[curSelected].stepsPerBeat); } } - if (!disableAsyncLoading) Main.execAsync(huh); - else huh(); + + if (!streamed) { + var huh:Void->Void = function() { + var soundPath = curPlayingInst; + var sound = null; + if (Assets.exists(soundPath, SOUND) || Assets.exists(soundPath, MUSIC)) + sound = Assets.getSound(soundPath); + else + FlxG.log.error('Could not find a Sound asset with an ID of \'$soundPath\'.'); + + if (sound != null && autoplayShouldPlay) { + FlxG.sound.playMusic(sound, 0); + Conductor.changeBPM(songs[curSelected].bpm, songs[curSelected].beatsPerMeasure, songs[curSelected].stepsPerBeat); + } + } + if (!disableAsyncLoading) Main.execAsync(huh); + else huh(); + } } songInstPlaying = true; - if(disableAsyncLoading) dontPlaySongThisFrame = true; + if (disableAsyncLoading && !Options.streamedMusic) dontPlaySongThisFrame = true; } #end @@ -423,8 +436,8 @@ class FreeplayState extends MusicBeatState changeDiff(0, true); #if PRELOAD_ALL - autoplayElapsed = 0; - songInstPlaying = false; + autoplayElapsed = 0; + songInstPlaying = false; #end coopText.visible = songs[curSelected].coopAllowed || songs[curSelected].opponentModeAllowed; diff --git a/source/openfl/utils/Assets.hx b/source/openfl/utils/Assets.hx index eef85212..f0c47e83 100644 --- a/source/openfl/utils/Assets.hx +++ b/source/openfl/utils/Assets.hx @@ -241,7 +241,7 @@ class Assets return null; } - public static function getMusic(id:String, useCache:Bool = true):Sound + public static function getMusic(id:String, useCache:Bool = true, staticFallback:Bool = true):Sound { #if (lime_vorbis && lime > "7.9.0" && !macro) if (Options.streamedMusic) { @@ -251,7 +251,7 @@ class Assets if (vorbisFile != null) return Sound.fromAudioBuffer(AudioBuffer.fromVorbisFile(vorbisFile)); } #end - return getSound(id, useCache); + return if (staticFallback) getSound(id, useCache); else null; } /**