This is the main boilerplate, all processing logic is contained here. Depending on the phase the ad is in (a single ad can have multiple phases from loading to the ending) each of them is handled here and an appropriate AdPlayback event is dispatched to the backend.