Detect when the video has ended

Working with an undocumented api is always fun. Thankfully this thread
http://stackoverflow.com/questions/6086205/ pointed me in the right
direction. The relevant play states are:
100: Buffering
101: Playing
102: Paused
104: Ended (Seek)
Whilst the play state is a representation of numerous flags, in reality
once the video has loaded, it is always in a buffering state. From there
we only have to determine which user operation is being run. This is where
setInterval and console.log came in handy whilst debugging the hosted
player.