media.newEventSound()

Type Function
Library media.*
Return value Userdata
Revision Current Public Release (2017.3068)
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( filename [, baseDir] )
filename (required)

String. Short description goes here.

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

Example

local soundID = media.newEventSound( "beep.mp3" )
local playBeep = function()
    media.playEventSound( soundID )
end
timer.performWithDelay( 1000, playBeep, 0 )