I’m trying to make an app that can record and playback sounds. It works exactly as I want it to in the Corona Simulator but when I put it on my phone (Galaxy S5) it does not work.
Here is the relevant code:
local TMP\_FILE\_NAME = "tmp.wav" --Name to store temporary file as local curStream = nil local audioHandle = nil local filePath = system.pathForFile(TMP\_FILE\_NAME, system.TemporaryDirectory) local function startCapture() curStream = media.newRecording(filePath) curStream:startRecording() end local function endCapture() if curStream then curStream:stopRecording() curStream = nil end audio.dispose(audioHandle) audioHandle = audio.loadSound(TMP\_FILE\_NAME, system.TemporaryDirectory) print(audioHandle) --Valid Object in the simulator, nil on phone! end local function playSample() audio.play(audioHandle, {channel = 1}) end local function stopSample() audio.stop(1) end
For some reason audio.loadSound returns nil on the phone but not in the simulator.
Any help? Thanks.