How to detect when mutliple events happen in rapid succession?

When I get out of the car, my phones Spotify stops playing and the charging state goes from charging to discharging.
I want to use this sequence of events as an automation trigger. Is there a built-in way to detect these events happening one after the other?

You could write an automation that trigger on spotify stopping and then add a wait_for_trigger for the discharging state.