I can record audio and play it back but i can’t figure out how to save it in a folder within the ResourceDirectory.
If I have a folder called “audioRec” in the folder with the main.lua file, how can I record and save the audio in that folder.
Just to note, I tried changing system.DocumentsDirectory to system.ResourceDirectory but recording doesn’t work. So, I’m still not sure how the whole Save audio thing works.
[lua]
audio.isChannelActive=false
local button = display.newRect( 200, 300, 75, 75 )
button:setFillColor( 0, 1, 0 )
local buttonStop = display.newRect( 200, 400, 75, 75 )
buttonStop:setFillColor( 1, 0, 0 )
local filePath = system.pathForFile( ‘record1.aif’, system.DocumentsDirectory )
local r = media.newRecording( filePath)
local audioHandle = nil
local audioChannel = nil
local function recordAudio( )
if (audioHandle ~= nil) then
--stop audio before disposing it
if (audio.isChannelActive(audioChannel)) then
audio.stop(audioChannel)
end
audio.dispose(audioHandle)
end
r:startRecording()
end
local function stopAndPlaybackRecording( )
r:stopRecording()
audioHandle = audio.loadSound( “record1.aif”, system.DocumentsDirectory )
audioChannel = audio.play(audioHandle)
end
button:addEventListener( “tap”, recordAudio )
buttonStop:addEventListener( “tap”, stopAndPlaybackRecording )
[/lua]