WordPress video end function [duplicate]

You can track the state of the youtube video, do you have the link to the youtube video? Use this youtube API function to get the result, and if it hits you back with a “0” you can initiate the alert(); function

player.getPlayerState():Number

Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).