How to Determine Whether Audio File Has Completed Playing?

In my app, upon touch events I play various short audio files using the media.playEventSound API.
I want to call a particular function once one of these audio files is done playing. Is there a way to do this? I didn't see an "IsPlaying" or similar method. If this can't be done with media.playEventSound, does the audio API allow this?

The openAL audio library does allow for this and is more advanced and flexible than the eventSound api.

I would suggest using the openAL audio api :)

http://developer.anscamobile.com/reference/index/audioischannelplaying

Danny, could you tell what's the name for event listener? I want to listen for event.completed, but can't find this in the docs.

http://developer.anscamobile.com/reference/index/audioplay

You can use the last parameter "onComplete =" to execute a function upon the sound completing playing.

eg

1
2
3
4
5
local function doWhenPlaybackComplete(event)
    print("Audio playback finished")
end
 
audio.play(myAudio, {loops = 1, onComplete = doWhenPlaybackComplete})

Oh, I missed that. Thanks a lot!

views:1641 update:2011/10/11 8:57:46
corona forums © 2003-2011