You might add a comment liking this call to pause() to the code in the ended event handler, and say that if we don't pause here then the ended event will make us skip to the beginning and pause there.