media.newEventSound()

Type Function
Library media.*
Return value Userdata
Revision Release 2024.3703
Keywords media, event sound, sound, audio
See also media.playEventSound()

Overview

Loads the event sound (1-3 seconds) from a sound file and returns an event sound ID that can be passed to media.playEventSound().

Syntax

media.newEventSound( audioFileName [, baseDir] )
audioFileName (required)

String. The name of the audio file you want to load.

baseDir (optional)

Constant. If specified, this argument is the directory where the sound file is located. If missing, the default is system.ResourceDirectory. Other options include:

  • system.DocumentsDirectory
  • system.ApplicationSupportDirectory
  • system.TemporaryDirectory
  • system.CachesDirectory

Gotchas

Example

local soundID = media.newEventSound( "beep.mp3" )

local playBeep = function()
    media.playEventSound( soundID )
end

timer.performWithDelay( 1000, playBeep, 0 )