Audio recording not working on Sony Experia devices

Hi there,

I’ve had a number of e-mails from people using our app on Sony Experia devices running Android 7 who have claimed that the audio record function within our app isn’t working all the time.

We couldn’t replicate on any of our Android devices, so we bought a Sony Experia phone and sure enough, the audio recording only works about 40% of the time.

No error comes up when recording, but I see the following error when trying to play back a failed recording:

04-25 14:39:05.660 32321 32371 I Corona  : WARNING: audio.loadSound() failed to create sound ‘word-1.wav’

This code has worked fine for 3 years on Android devices but with Android 7 we are starting to see this issue. The really frustrating thing is that the problem is sporadic - it happens 3 times in a row and then the recording works fine, with no difference to what I’m doing.

Recording:

local filePath = system.pathForFile( "word-1.wav", system.DocumentsDirectory ) r = media.newRecording( filePath) r:setSampleRate(44100) r:startRecording()

Play back:

local sound = audio.loadSound( "word-1.wav", system.DocumentsDirectory ); local sChannel = audio.play( sound, { onComplete = nil } );

If anyone else has experienced this or has any ideas that would be really helpful.

Thanks in advance,

Ian

Hi @keystagefun,

It’s probably not the issue, but can you let the recording use the “default” sample rate instead of setting it outright? I know you’re setting it to the default, but it doesn’t hurt to eliminate that as a fringe possibility.

You also said this is only Android 7 devices? Android 6 and earlier works as expected?

Thanks,

Brent

Hi Brent.

I think I’ve “fixed” it but I’m not sure I understand why!

It became apparent that the file was being recorded, as I could access it and see it was there, but there seemed to be something about intermittently recorded files that didn’t allow them to be played back on some Android 7 devices (customers also reported this).

I looked at the code for your simple audio recorder app and the only difference is that on playback, you use  audio.loadStream instead of  audio.loadSound.

So I changed it and now it works perfectly every time.

The issue is definitely with the recording, in that if a particular recording fails then it ALWAYS fails on playback, whereas if it’s successful, it’s always successful on playback. So something in the recording process is intermittently causing certain files to become corrupted (?) and unplayable using audio.loadSound, but playable using audio.loadStream.

I don’t like the “fix” I’ve got as it suggests there is still an issue with the original recordings, but it’s working so for the moment that’s something.

Any idea why something like this might occur?

Cheers,

Ian

Hi Ian,

How/when does a recording “fail” in your app?

Hi @keystagefun,

It’s probably not the issue, but can you let the recording use the “default” sample rate instead of setting it outright? I know you’re setting it to the default, but it doesn’t hurt to eliminate that as a fringe possibility.

You also said this is only Android 7 devices? Android 6 and earlier works as expected?

Thanks,

Brent

Hi Brent.

I think I’ve “fixed” it but I’m not sure I understand why!

It became apparent that the file was being recorded, as I could access it and see it was there, but there seemed to be something about intermittently recorded files that didn’t allow them to be played back on some Android 7 devices (customers also reported this).

I looked at the code for your simple audio recorder app and the only difference is that on playback, you use  audio.loadStream instead of  audio.loadSound.

So I changed it and now it works perfectly every time.

The issue is definitely with the recording, in that if a particular recording fails then it ALWAYS fails on playback, whereas if it’s successful, it’s always successful on playback. So something in the recording process is intermittently causing certain files to become corrupted (?) and unplayable using audio.loadSound, but playable using audio.loadStream.

I don’t like the “fix” I’ve got as it suggests there is still an issue with the original recordings, but it’s working so for the moment that’s something.

Any idea why something like this might occur?

Cheers,

Ian

Hi Ian,

How/when does a recording “fail” in your app?