How do library book detectors work?
Two of the common library book detection systems are magnetic strip based (e.g. 3M Tattle-Tape), and RFID library management systems (see this publication).
The magnetic systems work by embedding a double-layered strip of material into the book cover or spine, where one strip is a permanent magnet polarized one way, while the other strip is a magnetizable strip that gets polarized one way or the other by the sensitizing / desensitizing device at the check-out desk.
If both strips are polarized in the same direction, the resultant strip has a high magnetic field, while polarizing them in opposite directions causes the fields to pretty much cancel out.
Detection masts at the library exits (again taking the 3M example) detect this magnetization as a "wobble" in the magnetic field when a book that has not been checked out passes through - a desensitized strip does not cause a detectable wobble.
RFID library management systems cost more per strip, but provide the added benefit of specific book identification. These do work the way the question suggests: An RFID tag with an embedded radio frequency antenna and transponding circuitry with an unique ID is embedded within each book, again possibly concealed in the spine or in a cover pocket.
The RFID "tag" is energized by RF energy emitted by the sensing masts. The tag's RF coil picks up this energy, which is then rectified and used to power the circuitry within the tag. The transponder then responds with the ID of the tag, and hence of the book.
In neither system is there any field detecting the charging of a capacitor, as posited in the question.
What is it about headphones that makes the buzzing?
The detection masts at the exits emit some electromagnetic signal. Especially in the case of the magnetic strip systems, this signal is of fairly low frequency, which can cause corresponding ripples in the amplification circuitry of the headphones. A small ripple in the input stage of amplification evidently will convert to a strong buzz after amplification. This can be partially or completely abated by suitable filtering incorporated into the headphone's amplifier.
Depending on the shielding and filtering incorporated in the headphones, it is worthwhile examining their behavior when passing between shopping mall loss-detection masts. Also, some headphones will even pick up a buzz when moved close to a conventional domestic CCFL lamp, many of which emit electromagnetic signals at 30-50 KHz.