Don't set AL.BYTE_OFFSET immediately after calling AL.sourcePlay

The sourcePlay call in NativeAudioSource.play is removed, since
setCurrentTime will always do that itself. Additionally, within
setCurrentTime, sourcePlay was happening before setting the byte
offset for non-streamed sounds.

This appears to fix the problem of sounds playing the first part
multiple times, described here:
https://community.openfl.org/t/sounds-play-twice-on-ios/12163
This commit is contained in:
Justin Espedal
2022-07-03 16:56:51 +09:00
parent 4f83af5848
commit b4110480c1

View File

@@ -187,8 +187,6 @@ class NativeAudioSource
{
var time = completed ? 0 : getCurrentTime();
AL.sourcePlay(handle);
setCurrentTime(time);
}
}
@@ -417,7 +415,7 @@ class NativeAudioSource
else if (parent.buffer != null)
{
AL.sourceRewind(handle);
if (playing) AL.sourcePlay(handle);
// AL.sourcef (handle, AL.SEC_OFFSET, (value + parent.offset) / 1000);
var secondOffset = (value + parent.offset) / 1000;
@@ -430,6 +428,7 @@ class NativeAudioSource
var totalOffset = Std.int(dataLength * ratio);
AL.sourcei(handle, AL.BYTE_OFFSET, totalOffset);
if (playing) AL.sourcePlay(handle);
}
}