The AC electromagnetic brake works by using a magnetic field to create a force that opposes the rotation of the shaft. This force is created by the interaction of the magnetic field with the electric current in the brake coils. When the brake is applied, the current in the coils is increased, which creates a stronger magnetic field. This stronger field creates a greater force that opposes the rotation of the shaft, causing the brake to slow down or stop the rotation.