Questions about Active Noise Cancellation
That's a pretty broad question. Let's start with a noise cancelling head set, that's about the easiest device.

A ANC headset has an internal microphone, that's placed as close to the ear canal as possible. It than runs a regular control loop (http://en.wikipedia.org/wiki/Control_theory): It calculates a speaker signal that tries to keep the signal at the microphone at zero. If you want to play music at the same time, you simply make the "desired signal" to be the music and not zero.

However, there are all sorts of implementation problems


Designing the control loop is difficult in terms of stability, cancelling performance, spectral fidelity, etc.
Manufacturing tolerances
Control loops need to be fast, so they work better at low frequencies. Most good headsets use a well tuned combination of active and passive cancellation. Passive works a lot better at high frequencies
While the headset cavity is small, it still has a fair amount of acoustic resonance and wave propagation, so you need to correct for the sound at the microphone vs. the sound at the ear drum
Many newer headsets use outside microphones as well, so it's a combination of feed-forward and feedback cancellation


Once the spaces get larger than a headset, things get a lot more complicated. Now you need to take into account the spatially distributed sound field, the environment, all kinds of propagation modes.