Type Function Library media.* Return value none Revision 2018.3297 Keywords media, play, sound, audio See also media.getSoundVolume() media.setsoundVolume() media.pauseSound() media.stopSound()
Because of various limitations outlined below, it is recommended that the audio library be used for playing back audio.
Plays an extended sound
You can optionally specify a callback function to be called whenever playback has finished.
Only one sound can be playing using this sound API. Calling this API with a different sound file will stop the existing sound and play the new sound.
Supported audio formats vary
media.playSound( soundfile [, baseDir] [, onComplete] ) media.playSound( soundfile [, baseDir] [, loop] )
String. Name of the sound file. The file must be in a format that is supported by the platform.
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:
Function. If specified, this argument is a completion listener (callback function) that will be called each time the sound finishes playing.
true, the sound will be played repeatedly. The default is
media.playSound( "song.mp3" ) local function stopAfter10Seconds() media.stopSound() end timer.performWithDelay( 10000, stopAfter10Seconds )