flambe
flambe copied to clipboard
Default sound playback volume is NaN AIR-iOS
For some reason the Air+iOS build makes these default parameters NaN, and not 1.0 - so you hear nothing unless passing a value in. There are no errors or warnings.
I worked around it with a conditional check for the NaN value in FlashSound .play and .loop
if (air && ios)
if (Math.isNaN(volume)) volume = 1.0;
end
Oh, weird. This seems like a bug in the Haxe / AIR iOS compiler. Can you reproduce it with a default Float param in your own code on iOS?
Hmm, good question :-) I don't have access to an iOS device at the moment, but can check it next week.
Interestingly, I decompiled the main-ios.swf in question and it looks like the issue could be in how Flash/Haxe treats optional/default parameters on interfaces.
When decompiled, the flambe.sound.Sound::play interface looks like this:
function play(_arg1:Number=undefined):Playback;
Whereas the actual platform.flash.FlashSound::play function looks like:
public function play(_arg1:Number=1):Playback{ return (new FlashPlayback(this, _arg1, 0)); }
So I imagine what could be happening is that: I create a Sound, call play on it, and (when compiled) the default parameter is undefined and that then gets passed on to FlashSound::play
(still.. that doesn't really explain why it's not an issue on Android. I guess it be a difference in the handling of undefined / NaN volume settings between the iOS and Android packagers)
Filed an issue over at HaxeFoundation/haxe#2431.