Rotate camera if player is about to go out of its view?

thanks! but how would i do that… can you explain in details ??