thanks! but what I meant is not only to make the code smaller, but to make it runnable on the web editor so we can easily test. We are all volunteers and if you ask a question with a small example that everyone can try easily, you will have a higher chance of someone solving your issue. If you upload a code that requires someone to tidy up and upload own samples, you are asking more work from them and you will have less chance to get a meaningful reply.
So I made a sketch from scratch to show how to play two files sequentially
https://editor.p5js.org/micuat/sketches/bTotDJ-Zj
The problem with addCue is that if you specify the actual duration of the sample, it seems it won’t fire it so I subtracted the duration with a small number. This is not an elegant solution. I added as a comment that you can instead use setTimeout. This is a javascript function that you can set the timing to fire a function, and this may be better. I hope this helps!