You might want to check out this example which listens for whether an audio file has 'ended':
If that doesn't do the trick, can you share what you have so far?