Disclaimer: This issue persists with HaxeFlixel projects. It was suggested that the cause may lie within OpenFL. I have opened an issue on the OpenFL GitHub repository.
The Problem: Every odd start of the game, it doesn’t have any sound. This has been happening across projects.
I’ve prepared a completely clean template project, with the Main.hx looking like this:
package;
import flixel.FlxGame;
import openfl.display.Sprite;
class Main extends Sprite
{
public function new()
{
super();
addChild(new FlxGame(256, 192, TitleScreen, 1, 60, 60, true));
}
}
And the TitleScreen.hx looking like this:
package;
import flixel.FlxG;
import flixel.FlxState;
class TitleScreen extends FlxState
{
override public function create():Void
{
#if flash
FlxG.sound.playMusic("assets/music/mysound.mp3");
#else
FlxG.sound.playMusic("assets/music/mysound.ogg");
#end
super.create();
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
}
}
The Project.xml is unchanged and the only two assets are the two mp3/ogg files.
While the windows target runs the game without sound, the neko target crashes whenever the issue occurs, tracing this:
Build succeeded
Done(0)
haxelib run lime run "Project.xml" neko -debug
Running process: D:\Pizza\Development\HaxeToolkit\haxe\haxelib.exe run lime run "Project.xml" neko -debug
Sound.hx:118: Error: Could not load "assets/music/mysound.ogg"
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
Invalid operation (/)
Called from flixel.system.FlxSound::update line 241
Called from flixel.system.frontEnds.SoundFrontEnd::update line 273
Called from flixel.FlxGame::update line 696
Called from flixel.FlxGame::step line 648
Called from flixel.FlxGame::onEnterFrame line 493
Called from openfl._legacy.events.EventDispatcher::dispatchEvent line 98
Called from openfl._legacy.display.DisplayObject::__dispatchEvent line 182
Called from openfl._legacy.display.DisplayObject::__broadcast line 161
Called from openfl._legacy.display.DisplayObjectContainer::__broadcast line 280
Called from openfl._legacy.display.Stage::__render line 1103
Called from openfl._legacy.display.Stage::__checkRender line 351
Called from openfl._legacy.display.Stage::__pollTimers line 1084
Called from openfl._legacy.display.Stage::__doProcessStageEvent line 430
Done(1)
Clues:
The problem does occur on the windows target, resulting in no sound.
The problem does occur on the neko target, resulting in a crash.
The problem does not occur on the flash target.
The problem does not occur when running the game in fullscreen mode (with FlxG.fullscreen = true;).
The problem does not occur when disabling windows visual designs (aero).
.zip of the project:
.zip of the windows cpp bin directory:
Thank you very much in advance.