Publish events for tracking logs

This time, this is a single pull request, as my workflow wasn't as clean as usual.

Also, there is plenty of repetition, but I see no clean way to factor it out.
I thought about this myself, but checking in my (chromium) browser, it seems that PLAYED is triggered only when the video reaches the end and stops.