Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

play does not work correctly for some content #1100

Closed
octplane opened this issue Aug 30, 2022 · 4 comments
Closed

play does not work correctly for some content #1100

octplane opened this issue Aug 30, 2022 · 4 comments

Comments

@octplane
Copy link

When using Hashlink, it seems very difficult to have the engine play something that should play for some time, such as a background music. It starts and stops after 200-300ms, something like that.

import hxd.snd.SoundGroup;
import hxd.res.Sound;

class Soundz extends hxd.App {
	var musicResource:Sound = null;

	override function init() {
		hxd.Res.initEmbed();
		startMusic();
	}

	function startMusic() {
		if(hxd.res.Sound.supportedFormat(OggVorbis)){
			musicResource = hxd.Res.sound.mutecity;
			if(musicResource != null){
				var sg: SoundGroup = new SoundGroup("hop");
				sg.mono = true;
				musicResource.play(true, sg);
			}
		}
	}

	override function update(dt:Float) {
	}

	static function main() {
		new Soundz();
	}

}
oct@Hokusai bin % haxe --version
4.2.5
oct@Hokusai bin % hl --version
1.12.0

compile.hxml:

-cp src
-D windowSize=640x480
-hl hello.hl
-lib heaps
-lib hlsdl
-main Soundz
--resource res/sound/mutecity.ogg@mutecity
@octplane
Copy link
Author

For some reason, trying to build the html output for the same sample code fails earlier during the Resource resolution:

-cp src
-D windowSize=640x480
-lib heaps
-js bin/game.js
-main Soundz
--resource res/sound/mutecity.ogg@mutecity
oct@Hokusai hello % haxe js.hxml
src/Soundz.hx:14: characters 20-42 : hxd._res._Sound has no field mutecity

@MSGhero
Copy link
Contributor

MSGhero commented Aug 30, 2022

It sounds like this, from ZwodahS in discord:

Sound bug in heaps, See
#1068
HaxeFoundation/haxe#10682

A simple fix is to put this line in your App.init
@:privateAccess haxe.MainLoop.add(() -> {});

@octplane
Copy link
Author

A simple fix is to put this line in your App.init
@:privateAccess haxe.MainLoop.add(() -> {});

Thanks!

@octplane
Copy link
Author

Duplicate of #1068

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants