Video Gallery Carousel

I’m working on a project that’s already been completed, not by me, except now another operation has to be added. Basically there is carousel that has thumbnails and when you click a thumbnail an external video loads and plays. But when the video is over it just stops and the player doesn’t go anywhere. If you click the player however it will go back to the carousel. What it needs to do now though is automatically go back to the carousel when the video is done and I want to use that same function it uses when the player is clicked. Problem is I’m not sure where to start. Any ideas on how to go about this? Thanks!