Channel position/Sound looping broken

Hello,

I’m trying to have a sound play from 0.0 and then loop from a different point.

This is what I had (or something along these lines; this code is written mostly blind):

var sound:Sound = Assets.getSound("my/path.ogg");
var transform;
var channel = sound.play(0, 0, transform);
channel.addEventListener(Event.SOUND_COMPLETE, complete);

var loopingPoint:Float = 1.2; // For example

function complete(_)
{
    channel = sound.play(loopingPoint, 0, transform);
}

This doesn’t seem to work after the first loop, as not only the event is not dispatched, as the sound effectively gets cut off early.

Using OpenFL 3.6.1 and Lime 2.9.1, due to HaxeFlixel :sweat:

Thanks in advance for the help.

Does it work in Flash? Have you tried this sample code with a newer version?

(Since Flash target wraps the Sound class to the AS3 sound class, and requires a different sound format, does it matter if it works?)

I’ll try these later today and report back :slight_smile:

Both are good sanity checks :slight_smile:

With the most recent version of OpenFL and Lime, the issue presists – the sound gets cut off early ~1 second, even on flash.

(So, sanity check done :slight_smile: )

It is telling that Flash Player behaves this way, as you pointed out earlier, we don’t have control over how it behaves.

Do you need to add another event listener after creating a new sound channel in the complete function, or should you give that a number of loops rather than manually looping?

Indeed!

Giving it a number of loops forces a loop from 0 to length; I was manually handling loops because I needed to play the whole clip but then only loop a section.

It’s a really strange issue to go undiscovered though; replaying a sound cuts it off??

(Plus I was expecting it to be some kink with OpenAL; the fact that it extends to flash weird sme out even more)

Woops, misread, sorry! Sound is still cut off adding a listener to the new channel (although consistently and looping to the correct point). Setting a number of loops on the channel loops from 0-length, even if the starting point isn’t 0.

Just say a35cd54, thank you @singmajesty for the quick fix :slight_smile:

edit

Oh, I was hoping that would’ve fixed it, seems not…

Try this:

This won’t work perfectly on HTML5, considering changing to a new library.

Oh, actually the above fixes might not apply to what you’re looking at. Recent commits improve the currentTime value, and improve looping support, but that would only affect setting the number of loops when you call play

1 Like