Keep entities in view using only zoom

I am trying to control the camera so that during playback, two moving entities are kept in view, by moving the camera forward and backward along it’s current direction. I’m already using an EntityView to keep the camera looking at the midpoint between the entities, it’s just at some points in playback, the entities can go outside the camera’s field of view given it’s heading/pitch.

Any help would be greatly appreciated.