I know that sound has been an issue over the years with iOS devices, but I have yet to find a solution in the archive. My compiled Haxe+OpenFL program runs fine on all devices but sound will not play on iOS. Does anyone know why?
Are you talking about html5? Or native?
If it’s a problem with html then you have to play any sound on mousedown/click event first, afterwards all sounds should work fine.
I target HTML5 (scripting in Flashdevelop using Haxe + OpenFL). Here’s a link to the prototype of the game (http://roomrecess.com/Haxe/BoomBlocks/play.html). Do I need to code the mousedown/click event through html or through Haxe?
Haxe is fine, something like this should work:
function init()
{
stage.addEventListener(MouseEvent.MOUSE_DOWN, fixSound);
}
function fixSound(e:MouseEvent)
{
var fix:Sound = Assets.getSound('assets/fix.mp3'); //any sound will be fine
fix.play()
stage.removeEventListener(MouseEvent.MOUSE_DOWN, fixSound);
}
You could also add “START GAME” button to your game, play the sound on button click and start the game.
Thanks man! I’ll give it a shot. I have a lot of little users that will be happy with sound.
Still no luck. I tried both solutions. Works fine on everything but iOS.
hi,
assuming openfl 3.6.1 and lime 2.9.1,
inside a command line create a sample test with
“openfl create playingsound”
edit main.hx and replace
#if flash
sound = Assets.getSound (“assets/stars.mp3”);
#else
sound = Assets.getSound (“assets/stars.ogg”);
#end
with
sound = Assets.getSound ("assets/shortsound.mp3");
modify project.xml with
assets path="Assets" rename="assets" embed="false" if="html5"
add a short and loud mp3 in assets in the assets/sound directory
then build with : openfl build html5
it should now run on anything. At least, on my computer : edge, firefox and chrome and my iphone.
_jb
I think that did it. At least on the test project. Now I’ll try to see what it does in the game. Thanks a lot!
Confirmed. Both things that were recommended worked! I host a site for kids (RoomRecess.com), and we’re trying to go mobile through HTML5. Now, thanks to you two, we can! Very appreciative!