loudo
October 11, 2018, 10:16am
#1
Hello,
I would like to load some files after the preloader. I tried the following without success:
in project.xml
<assets path="assets/sounds_preload" rename="sounds" preload="true"/>
<assets path="assets/sounds" rename="sounds" library="sound_background" embed="false" preload="true"/>
in Main.hx
Assets.loadLibrary("sound_background");
The sounds in folder sounds_preload are preloaded as expected but when I call loadLibrary for the other sounds, nothing are loaded.
I just tried the following steps:
1.) openfl create PlayingSound SoundPreloadTest
2.) Changed project.xml
to have this assets line: <assets path="Assets" rename="assets" library="delayed" />
3.) Wrapped the code in the constructor around a library load call
Assets.loadLibrary ("delayed").onComplete (function (library) {
Actuate.defaultEase = Quad.easeOut;
background = new Sprite ();
background.alpha = 0.1;
background.buttonMode = true;
background.addEventListener (MouseEvent.MOUSE_DOWN, this_onMouseDown);
addChild (background);
#if flash
sound = Assets.getSound ("delayed:assets/stars.mp3");
#else
sound = Assets.getSound ("delayed:assets/stars.ogg");
#end
position = 0;
resize ();
stage.addEventListener (Event.RESIZE, stage_onResize);
play ();
});
I tested on Neko, HTML5 and Flash. Flash did not play the sound (for some reason) but Neko and HTML5 are working for me
loudo
October 13, 2018, 2:30pm
#3
Hi,
thanks for your reply. It is working!
BUT if you add embed=“false” in the project.xml, it is not working anymore. That was my mistake!
Any explanation of this?
I don’t think HTML5 supports embedded sounds, because of the way it interacts with howler.js. This could be an interesting thing to look at, if we could workaround that limitation