Event

audio:start

Client

Fired when an audio instance starts playing

Signal

"audio:start"

Fires once per playback, not once per loop.

  • Trigger — triggered by self:play when the audio was not already playing, and by autoplay on a freshly created audio.
  • Already playing — calling self:play on audio that is already playing restarts it silently and does not fire the signal.
  • Resuming — resuming from self:set_paused does not fire the signal, the playback never stopped.
  • Audio types — fires for both core.audio_2d and core.audio_3d. Use audio:is_type to tell them apart.
  • Detection — detected once per frame, so a play followed by a stop inside the same frame may not be reported.

Arguments

TypeNameDescription
core.audio_2d | core.audio_3daudioAudio instance that started playing

Example

React when a sound starts playing
local entity = core.audio_2d.create("sounds/ambient.ogg")

util.event.on("audio:start", function(audio)
    core.engine.print("info", "Audio started at:", audio:get_playback_position())
end)

entity:play()

On this page