No audio playing on my iPhone at all.

Hey all,

I’m working on my first Corona app, and everything looks and sounds great in the simulator. On the device, however, it only looks great: no audio is playing at all. I have an animation that gets triggered when audio is played, and an oncomplete is set to flip the animation off once the audio finishes. The audio never plays and the oncomplete never fires. This is the function I use to play audio:

function playApology()     if (audioCurrentlyPlaying) then          return false     end          characters[apologyCharacter].mouth\_neutral.alpha = 0     characters[apologyCharacter].mouth\_sad.alpha = 1     characters[apologyCharacter].tear.alpha = 1     -- based on current character, randomly select a file     apologyToPlay = apologies[apologyCharacter][math.floor(math.random(#apologies[apologyCharacter]))]          -- currently, it always loads "bouncing.aac" from the "AudioPlayer" sample app         print("Playing this file", apologyToPlay)     -- load the file     apologyFile = audio.loadSound(apologyToPlay, system.ResourceDirectory)          print("Apology File: ", apologyFile)         -- debug\_loadsound.text = apologyToPlay          -- play the file          local aa = audio.play(apologyFile, {onComplete=killApologyAudio})          print (aa)     audioCurrentlyPlaying = true     rot\_dir = -1 end

As you can see, it’s pretty straightforward. I thought it might have been an issue with my audio files, but I tried wav (16 bit uncompressed), MP3 and AAC. I am currently trying the “bouncing.aac” file that’s in the “AudioPlayer” sample app, but nothing’s working.

I’m running an iPhone 5S with iOS 7.1.2. Any ideas what’s up? Do I need to call something to get permissions to play audio on the device, or anything like that?

Thanks!

Hi @hoggworks,

Can you try building and installing the AudioPlayer sample app and reporting back if you hear sounds on your phone?

Thanks,

Brent

It does, actually! 

One thing I notice is that in my app when I hit the volume buttons nothing happens; the square with the volume level doesn’t show up on the screen. Any idea why audio wouldn’t be initialized?

Hmmm, my guess would be that there’s a Lua reference/scope issue, or something where it’s not recognizing the audio handle or file. Have you read through the Audio Usage guide yet? This should be a starting point before you continue, so you fully understand the audio system, sounds vs. streams, handles, when to load thing, how to dispose of audio, etc.

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

Best regards,

Brent

I think I figured out what it is. My app is constantly trying to get the active volume (for some background effects), but while that causes no issues in the simulator, it causes an issue in the device.  Damn it. 

Is there any way I can get it to play audio while doing a getTunerVolume?

Hi @hoggworks,

Can you try building and installing the AudioPlayer sample app and reporting back if you hear sounds on your phone?

Thanks,

Brent

It does, actually! 

One thing I notice is that in my app when I hit the volume buttons nothing happens; the square with the volume level doesn’t show up on the screen. Any idea why audio wouldn’t be initialized?

Hmmm, my guess would be that there’s a Lua reference/scope issue, or something where it’s not recognizing the audio handle or file. Have you read through the Audio Usage guide yet? This should be a starting point before you continue, so you fully understand the audio system, sounds vs. streams, handles, when to load thing, how to dispose of audio, etc.

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

Best regards,

Brent

I think I figured out what it is. My app is constantly trying to get the active volume (for some background effects), but while that causes no issues in the simulator, it causes an issue in the device.  Damn it. 

Is there any way I can get it to play audio while doing a getTunerVolume?