Add audio clip started and finished events to audio source

This commit is contained in:
Chandler Cox
2025-08-01 15:07:25 -05:00
parent f37b75df7b
commit 5c7712daad
2 changed files with 25 additions and 1 deletions

View File

@@ -168,7 +168,7 @@ void AudioSource::Play()
else
{
// Source was nt properly added to the Audio Backend
LOG(Warning, "Cannot play unitialized audio source.");
LOG(Warning, "Cannot play uninitialized audio source.");
}
}
@@ -395,6 +395,9 @@ void AudioSource::Update()
AudioBackend::Source::VelocityChanged(SourceID, _velocity);
}
if (Math::NearEqual(GetTime(), _startTime) && _isActuallyPlayingSth && _startingToPlay)
ClipStarted();
// Reset starting to play value once time is greater than zero
if (_startingToPlay && GetTime() > 0.0f)
{
@@ -416,6 +419,7 @@ void AudioSource::Update()
{
Stop();
}
ClipFinished();
}
}
@@ -486,6 +490,7 @@ void AudioSource::Update()
{
Stop();
}
ClipFinished();
}
ASSERT(_streamingFirstChunk < clip->Buffers.Count());
@@ -583,3 +588,11 @@ void AudioSource::BeginPlay(SceneBeginData* data)
SetTime(GetStartTime());
}
}
void AudioSource::EndPlay()
{
Actor::EndPlay();
ClipStarted.UnbindAll();
ClipFinished.UnbindAll();
}