diff --git a/src/lime/_internal/backend/native/NativeAudioSource.hx b/src/lime/_internal/backend/native/NativeAudioSource.hx index 0baa34071..c1d7de086 100644 --- a/src/lime/_internal/backend/native/NativeAudioSource.hx +++ b/src/lime/_internal/backend/native/NativeAudioSource.hx @@ -424,7 +424,7 @@ class NativeAudioSource timer.stop(); } - var timeRemaining = getLength() - value; + var timeRemaining = Std.int((getLength() - getCurrentTime()) / getPitch()); if (timeRemaining > 0) { @@ -483,7 +483,7 @@ class NativeAudioSource timer.stop(); } - var timeRemaining = value - getCurrentTime(); + var timeRemaining = Std.int((getLength() - getCurrentTime()) / getPitch()); if (timeRemaining > 0) { @@ -514,6 +514,22 @@ class NativeAudioSource { AL.sourcef(handle, AL.PITCH, value); + if (playing) + { + if (timer != null) + { + timer.stop(); + } + + var timeRemaining = Std.int((getLength() - getCurrentTime()) / getPitch()); + + if (timeRemaining > 0) + { + timer = new Timer(timeRemaining); + timer.run = timer_onRun; + } + } + return getPitch(); }