Audio complete event issue: can't receive on suspend

[build.settings]

UIApplicationExitsOnSuspend = false,

UIBackgroundModes = {“audio”, “remote-notification”},

[test code]

local function callbackListener( event )

    if event.completed then  – can’t receive on App suspended  :frowning:

           playNextMusic()

    end

end

handle = audio.loadStream(“test.mp3”)

audio.play( handle, { channel = 1, loops = 0, onComplete=callbackListener }  )

Can anybody help me?

Since it looks like you want the audio to play while suspended, you could on resume check to see if the audio has completed playing using audio.isChannelPlaying (https://docs.coronalabs.com/api/library/audio/isChannelPlaying.html) and if it’s not call the onComplete listener directly.

Rob

hi rob,

I think it is a timer issue.

UIBackgroundModes = {“audio”, “remote-notification”},

onComplete=callbackListener

Once my app is suspended, i will not be able to receive events from the timer.

i need audio complete event on suspended mode. (or other solution)

Unfortunately, Corona is not designed to run backgrounded. You will have to delay your onComplete listener until the app is in the foreground.

Rob

Since it looks like you want the audio to play while suspended, you could on resume check to see if the audio has completed playing using audio.isChannelPlaying (https://docs.coronalabs.com/api/library/audio/isChannelPlaying.html) and if it’s not call the onComplete listener directly.

Rob

hi rob,

I think it is a timer issue.

UIBackgroundModes = {“audio”, “remote-notification”},

onComplete=callbackListener

Once my app is suspended, i will not be able to receive events from the timer.

i need audio complete event on suspended mode. (or other solution)

Unfortunately, Corona is not designed to run backgrounded. You will have to delay your onComplete listener until the app is in the foreground.

Rob