Audio doesn't work on device

Hi,

I am creating the game with Corona SDK and I need to play an audio file. I have wrote the code and audio plays perfectly in the simulator but when I installed the app on the android tablet (Alcatel OneTouch), the sound doesn’t play. The file name is correctly written and it is saved in the main folder, where main.lua is.

Did somebody had the same problem and how can I solve it?

Best Regards!

Hi @hrvoje.ljubich,

Please refer to the audio guide and check if the format you’re using is compatible with Android:

http://docs.coronalabs.com/guide/media/audioSystem/index.html

Best regards,

Brent Sorrentino

Hi Brent,

thanks on the answer. I used the right format, it is .wav sound file. It works (plays) in the simulator but not on the android tablet. Here is the code I used to load and play sound:

local soundMusic = audio.loadSound("music.wav") audio.play(soundMusic)

Best regards!

Hello again,

Is this a long music file, like several MB in size?

No, it is a small 33kb file.

There might be something wrong with the actual file. Can you try loading another .wav file? There is one located in this folder in your Corona application folder:

CoronaSDK > SampleCode > Media > SimpleMixer > loop1.wav

Please try that on the device, and see if it works or not.

Brent

P.S. - what is the exact device you’re testing on?

Hi @hrvoje.ljubich,

Please refer to the audio guide and check if the format you’re using is compatible with Android:

http://docs.coronalabs.com/guide/media/audioSystem/index.html

Best regards,

Brent Sorrentino

Hi Brent,

thanks on the answer. I used the right format, it is .wav sound file. It works (plays) in the simulator but not on the android tablet. Here is the code I used to load and play sound:

local soundMusic = audio.loadSound("music.wav") audio.play(soundMusic)

Best regards!

Hello again,

Is this a long music file, like several MB in size?

No, it is a small 33kb file.

There might be something wrong with the actual file. Can you try loading another .wav file? There is one located in this folder in your Corona application folder:

CoronaSDK > SampleCode > Media > SimpleMixer > loop1.wav

Please try that on the device, and see if it works or not.

Brent

P.S. - what is the exact device you’re testing on?

I have the same issue. It seems this post has stopped without getting an answer. Has there been a solution?

I have the same issue. It seems this post has stopped without getting an answer. Has there been a solution?

I’m having the same problem, tried the loop1.wav and it works fully but nothing I try to record works on the devices, only on the simulator

Edit, I’ve tried to record using windows sound recorder, audacity, and a few online tools, none have produced files that will play on my devices

For anyone thats having this problem, my friend just told me a solution, use the following code:

–Create a sound array with all your sounds

soundFileArray = {“media/aSound.wav”, “media/bSound.wav”, “media/cSound.wav”, 

 “media/dSound.wav”, “media/eSound.wav”, “media/fSound.wav”, “media/gSound.wav”, }

–Load desired sound file from array

soundFile = audio.loadSound(soundFileArray[1])

–Play loaded sound file and dispose on complete

audio.play(soundFile,{

  loops = 0,  

  oncomplete = function(e)

   audio.dispose(e.handle);

   e.handle = nil; 

   

   end

   });

This should work with MP3s and WAVs

I’m having the same problem, tried the loop1.wav and it works fully but nothing I try to record works on the devices, only on the simulator

Edit, I’ve tried to record using windows sound recorder, audacity, and a few online tools, none have produced files that will play on my devices

For anyone thats having this problem, my friend just told me a solution, use the following code:

–Create a sound array with all your sounds

soundFileArray = {“media/aSound.wav”, “media/bSound.wav”, “media/cSound.wav”, 

 “media/dSound.wav”, “media/eSound.wav”, “media/fSound.wav”, “media/gSound.wav”, }

–Load desired sound file from array

soundFile = audio.loadSound(soundFileArray[1])

–Play loaded sound file and dispose on complete

audio.play(soundFile,{

  loops = 0,  

  oncomplete = function(e)

   audio.dispose(e.handle);

   e.handle = nil; 

   

   end

   });

This should work with MP3s and WAVs