Random mp3 and automatic closing

this app plays the mp3.1 file at the beginning, then randomly plays the mp3 files 2 to 4, and closes by playing the mp3.5 file
I would like to add the automatic closing of the app at the end of the playback of the last mp3 file, please someone tell me how to do it?
aaaa.aia (741.1 KB)

However currently file 5 will be played in a never ending loop...

In the else part of your if then else statement just check

if Player1.Source = 5.mp3
then close application 
else play 5.mp3


thank you for your reply, please, how should I fix the blocks to make that file 5 is not played in a loop?
how do you see each mp3 is accompanied by a text, how do I program to suspend the random playback of the mp3s and related texts and command that the last mp3 played is number 5? and how do I program the automatic closing of the app at the end of the mp3 number 5 playback?
Thank tou very much

@Taifun has shown you already.

In the WhenPlayerCompleted event, if the Player1.Source is 5.mp3 then close the application....

dear friend, i solved the first problem, thanks. to solve it I added a second player as you can see from the image of the blocks. but now I have to solve a second problem. of the group of random mp3 files the app plays only two and not all three. can you please suggest me how to do to make them reproduce all three


thank you very much

aaaa.aia (741.4 KB)

This is the basic random use and depletion cycle:

  • If items remain then
    • pick one
    • use it
    • remove it
  • else
    • quit

as it is a short suggestion, would you be kind enough to enter the correction on the aia file yourself, please? a thousand thanks.

These are draggable procedures.

Fill in the use_item procedure with what you want to do (play it?) with the selected item value.

Call the use_random_item procedure with your list of files, at startup and after a file finishes playing.

very kind of you, thank you very much