Remove redundant music checks in frontend methods - #3586
Conversation
|
@Geokureli This is a breaking change. It breaks any project that manually replaces From what I've gathered, Since it's no longer updated independently, projects that do the aforementioned now have music that doesn't update, which is especially problematic in FNF's case as the sound time no longer updates, and therefore the gameplay gets stuck |
|
Setting music directly is actually fairly common, I'm surprised I didn't think of that. I may revert this, but first I'll try a new PR that fixes the original issue without adding music to the list, I suppose |
Honestly didn't notice any problems with this. At most, music stopped playing after switching state, but this was solved simply by doing |
Can you share your code for playing music? |
Sure. I use wrapper around FlxG.sound.playMusic(): public static function mysic(?options:SoundOptions, ?n:String):Null<FlxSound> {
if (n != null)
musico = n;
final o:SoundOptions = options;
final lib:String = o?.library ?? 'sodaluv';
final m:Sound = Paths.sound(lib == 'sodaluv' ? 'music/$musico' : musico, lib);
if (m == null)
return null;
final msc:FlxSound = FlxG.sound.playMusic(m, o?.group, o?.volume ?? Fei.prf.musicVol, o?.loop ?? true, o?.onComplete);
msc.persist = true; //fixes mentioned issue
if (o?.time != null)
msc.time = o.time;
final prox:ProxData = o?.proximity;
if (prox != null) {
msc.proximity(prox.x, prox.y, prox.target, prox.radius, prox.pan ?? true);
if (prox.pitch != null)
msc.pitch = prox.pitch;
}
return msc;
} |
Thanks! It sounds like you're saying that, before this change, playMusic would always persist across state switches, and now it no longer does unless you specifically make it persist, is that correct? If so, I don't see why that would have changed, and I should look into it. Edit: I looked into it, it used to set persist to true, so I added that back. Thanks, again! |
Yes, you got it right. I was glad to help with it! |
Fixes #3580
Introduced in #3558
Now that music is added to
FlxG.sound.list(an unintended change, but not a bad thing)FlxG.sound.onFocusLostcalls music.onFocusLost twice. the second would set _resumeOnFocus to false since it was already pausedI'm not sure why music was not added to the list, I'll check for any other unintended side effects of this change before merging. That may have been be a breaking change, as if anyone checked the if the list contains the music, it would have been false, but is now true, but that seems like an odd thing to do.
I don't think I can unit test this, but i'll look and seeAdded tests