diff --git a/Source/Engine/Audio/AudioSource.cpp b/Source/Engine/Audio/AudioSource.cpp index c990332a0..8ba02ab76 100644 --- a/Source/Engine/Audio/AudioSource.cpp +++ b/Source/Engine/Audio/AudioSource.cpp @@ -338,6 +338,7 @@ void AudioSource::PlayInternal() AudioBackend::Source::Play(this); _isActuallyPlayingSth = true; + _startingToPlay = true; } #if USE_EDITOR @@ -419,6 +420,23 @@ void AudioSource::Update() AudioBackend::Source::VelocityChanged(this); } + if (!UseStreaming() && GetTime() == GetStartTime() && _isActuallyPlayingSth && !_startingToPlay) + { + if (GetIsLooping()) + { + Stop(); + Play(); + } + else + { + Stop(); + } + } + if (_startingToPlay) + { + _startingToPlay = false; + } + // Skip other update logic if it's not valid streamable source if (!UseStreaming() || SourceIDs.IsEmpty()) return; diff --git a/Source/Engine/Audio/AudioSource.h b/Source/Engine/Audio/AudioSource.h index 450edf44a..57aab9dc8 100644 --- a/Source/Engine/Audio/AudioSource.h +++ b/Source/Engine/Audio/AudioSource.h @@ -57,6 +57,7 @@ private: bool _clipChanged = false; bool _isActuallyPlayingSth = false; + bool _startingToPlay = false; bool _needToUpdateStreamingBuffers = false; States _state = States::Stopped;