Play_Ended is en event of the Threading Library and is called when the thread Play terminates. It should be called every time it finishes, but I didn't test it under this situation. You may need to incorporate a slight delay before restarting the thread. You could try this with a timer if you need to.
Other alternatives would be to set a notification marker (see the initialization method in the documentation
here or you could check the Playstate within a timer to see if the audiotrack is still playing.
The SineWave code was really designed as a quick experiment for playing sine waves as part of a discussion and is not the best place to start if you want to build an app.
For your experimentation, the best way to extend the playing time, would be to increase the Duration passed to Playsound.