Trigger automation when movie ends

Hi,
I’m using a roku streaming stick to play Netflix etc. The Media_Player widget correctly displays the position of the movie’s timeline. Is there a way to trigger an automation (such as pause netflix autoplay, turn on lights and music) once a movie ends/a new track begins or 99% of the timeline have been reached?

The state should change from playing to idle.