Interactive Video Program Lagging

it’s my first question here and I really need your help about an interactive video.
I put a tag in the HTML, and depending on which button I click, the source of the video changes to play the next one. The problem is that at some point an almost infinite loop is created and the buttons take longer and longer to appear. I have to show this video to my brother-in-law for his birthday which is Saturday, and I really need help fixing this problem.

Here is the whole code, the sentences are in French, but you should still understand what is going on.

https://github.com/DonGiuliani/Video-Interactive