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? [import]uid: 76002 topic_id: 14259 reply_id: 314259[/import]

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 :slight_smile:

http://developer.anscamobile.com/reference/index/audioischannelplaying [import]uid: 84637 topic_id: 14259 reply_id: 52578[/import]

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. [import]uid: 52103 topic_id: 14259 reply_id: 53051[/import]

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

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

eg

[code]
local function doWhenPlaybackComplete(event)
print(“Audio playback finished”)
end

audio.play(myAudio, {loops = 1, onComplete = doWhenPlaybackComplete})
[/code] [import]uid: 84637 topic_id: 14259 reply_id: 53362[/import]

Oh, I missed that. Thanks a lot! [import]uid: 52103 topic_id: 14259 reply_id: 53364[/import]