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

one question though… how would i know that my player is going out of the camera view toward the left or the right? its giving false on both side right now i dont know which direction to rotate my camera because of that?