def playmusic2(soundfile):
    """Stream music with mixer.music module using the event module to wait
       until the playback has finished.

    This method doesn't use a busy/poll loop, but has the disadvantage that 
    you neet to initialize the video module to use the event module.
    
    Also, interrupting the playback with Ctrl-C does not work :-(
    
    Change the call to 'playmusic' in the 'main' function to 'playmusic2'
    to use this method.
    """

    pygame.init()

    pygame.mixer.music.load(soundfile)
    pygame.mixer.music.set_endevent(pygame.constants.USEREVENT)
    pygame.event.set_allowed(pygame.constants.USEREVENT)
    pygame.mixer.music.play()
    pygame.event.wait()
Stream music with mixer.music module using the event module to wait
       until the playback has finished.

    This method doesn't use a busy/poll loop, but has the disadvantage that 
    you neet to initialize the video module to use the event module.
    
    Also, interrupting the playback with Ctrl-C does not work :-(
    
    Change the call to 'playmusic' in the 'main' function to 'playmusic2'
    to use this method.
    
recipes/Python/521884_Play_sound_files_pygame_crossplatform/recipe-521884.py