AudioSource length (duration) ignored in HTML5 [Lime]

I’m using Haxe Lime (6.5.0) without OpenFL.

I have an sound file that is split into 1 second oneshots. So I want to be able to trigger those individual oneshots in arbitrary order.

Here’s an example of how my code looks:

var oneshot = 3; // Pick the fourth oneshot (3000 milliseconds in)
var audioSource:AudioSource = new AudioSource(buffer, 1000 * oneshot, 1000);
audioSource.play();

For the C++ target, this works great!

For the HTML5 target, the “length” parameter seems to be ignored for all sound formats.
The entire sound plays. The “offset” parameter still works as expected though.

I’ve run this with OGG, WAV, and MP3, with identical results (though MP3 is not supported with C++).

Is this fixable from my end? I haven’t really done any other audio setup aside from the code provided.

This could be fixed by us using a timer. It’s not exact, but would be better than it not being implemented at all.

I believe Howler.js (which we use on HTML5 right now) does have support for “audio sprites”, but the problem is they need to be defined (to my knowledge) before the sound is loaded, which (I think) is not a nice way to use it.

Hey thanks!
In that case, I can definitely implement a timer from my end! That would be totally fine for now.
Glad to know it wasn’t an issue from my end!

I agree with you that audio sprites are a bit much for something like that. I suppose you’re right that that best option would be to use a timer until something better comes along.
Just there are those cases where JavaScript may hang while the audio plays, like if an alert is open at the time. That’s a problem that audio sprites would help mitigate. :slight_smile:

So I wonder if there’ll be a better way to do this in the future - I mean it’d be really cool to have unified audio sample streaming capabilities, like Flash had. But it just seems that audio dev is relatively limited through HTML5 currently.