The steps to play the music in a loop three times are as follows:
1. In the mini program development tool, open the mini program project and add the background music component to the interface where background music needs to be played.
2. Set the src attribute of the background music to point to the background music file that needs to be played.
3. Set the background music attribute loop to true to achieve loop playback, and add the variable count in the code to record the number of times the background music has been played.
4. Set the playback end event of the background music. When the background music ends, determine whether to play it again or stop by judging whether the count value is less than 3.