Type Function Library media.* Return value Recording Revision 2017.3060 Keywords media, recording, audio See also object:startRecording object:stopRecording media.playSound()
Create an object for audio recording (Recording).
This API is not supported on Windows Phone or tvOS.
build.settings
file:settings = { android = { usesPermissions = { "android.permission.RECORD_AUDIO", }, }, }
.wav
. To record to the .3gp
format, simply append .3gp
to the end of the path. Note that .3gp
files can only be played by the media.playSound() function.On iOS, to enable audio recording on devices, you must include the following keys/descriptions in the plist
table of build.settings
. When the system prompts the user to allow access, the associated description is displayed as part of the alert. Note that these descriptions can be customized to your preference and they can even be localized (guide).
settings = { iphone = { plist = { NSMicrophoneUsageDescription = "This app would like to access the microphone.", }, }, }
media.newRecording( [path] )
String. The path of the file in which to record audio data. If no file is specified, the output goes nowhere.
The following platforms can only record to the following audio formats:
Platform | Supported Audio Formats |
---|---|
iOS | .aif |
Android | .wav (default), .3gp (not supported by the "Nabi 2" tablet) |
macOS | .aif |
Windows | .wav |
local filePath = system.pathForFile( "newRecording.aif", system.DocumentsDirectory ) r = media.newRecording( filePath ) r:startRecording()