media.playEventSound()

Type Function
Library media.*
Return value none
Revision Current Public Release (2017.3068)
Keywords media, sound, event sound, audio
See also audio.*
media.newEventSound()

Overview

Plays an event sound (1-3 seconds). The first argument may be either an event sound ID or a filename for the event sound. This is recommended for short sounds, especially to avoid performance hiccups.

Gotchas

Syntax

media.playEventSound( sound [, baseDir] [, completionListener] )
sound (required)

Userdata or String. The first argument is either an event sound ID (from media.newEventSound()) or a filename for the event sound.

baseDir (optional)

Constant. If specified, this argument is the directory where the sound file is located, if you specified a filename for sound. The default is system.ResourceDirectory. Other options include:

  • system.DocumentsDirectory
  • system.ApplicationSupportDirectory
  • system.TemporaryDirectory
  • system.CachesDirectory
completionListener (optional)

Function. If specified, a listener function that will be called each time the event sound is played. Note, however, that Android does not support this functionality.

Example

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