Looping with loopTime doesn't work

  • Hello,

    I'm trying to play a file once from the start and then loop it from a fixed point:

    var sound:FlxSound = new FlxSound();
    sound.looped = true;
    sound.loopTime = 500;

    Any idea why this isn't working? The loop plays twice from 0-length and then stops.

  • After some experimenting:

    1. Documentation is wrong. loopTime is in seconds, not milliseconds.

    2. It seems it's openfl.audio.Sound that's flawed -- calling play with any number of loops works fine, but playing the same sound multiple times results in a cutoff at the end, as well as Event.SOUND_COMPLETE not being called.


    All this seems to apply only to next for whatever reason.

  • administrators

    Documentation is wrong. loopTime is in seconds, not milliseconds.

    I can't reproduce that. Is that on specific target?

    I've tested this by adding the following code to Mode's PlayState#create(). Tested on Flash and Neko (legacy).

    FlxG.console.autoPause = false;
    FlxG.watch.addExpression("FlxG.sound.music.time", "time");
    FlxG.watch.addExpression("FlxG.sound.music.length", "length"); // may require dev flixel
    FlxG.watch.addExpression("FlxG.sound.music.loopTime", "loopTime");

    You can then play around with loopTime using the debugger console (by running FlxG.sound.music.loopTime = 2000) for instance. This seems to work as expected.

  • administrators

    Update: I can reproduce this with -Dnext. Reported to OpenFL: https://github.com/openfl/openfl/issues/1290

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.