Auto-Pause on Disconnect
Pause, mute or unmute automatically when an external audio device connects or disconnects (wired headphones, Bluetooth, USB DAC).
Author: DpakB
Pauses what you were listening to when the headphones go away: the 3.5 mm cable
pulled out, a Bluetooth headset dropped, a USB DAC unplugged. The action lands
after Windows has moved the sound back to the built-in speakers, so there is no
one-second blast through them.

It does not have to be a pause. The action is a setting, and so is whether it
runs on a disconnect, on a connect, or both.
Features
- Watches the default output device, so wired, Bluetooth and USB removals are
caught the same way.
- Toggle play/pause, mute the output, or unmute it.
- Waits 300 ms by default before acting, which is enough for Windows to finish
moving the stream. Adjustable.
- Repeats inside one second are folded into a single action. One unplug raises
several notifications, and play/pause is a toggle.
- Only acts while an app is actually playing by default, so it never starts
playback on its own.
- Switching the output by hand is left alone; the old device has to be gone for
the action to run.
Settings
- When a device disconnects and When a device connects pick the
direction. Connects are off by default, because plugging headphones in moves
the default output too.
- Audio role to watch is Multimedia by default, or Console, or Both.
- Action is Toggle play/pause, Mute the default output, or Unmute it.
- Delay before acting (ms) is how long Windows gets before the action runs,
0 to 3000.
- Ignore repeats within (ms) is the window used to fold the burst, 0 to 5000.
- Act only while audio is playing keeps the toggle from starting playback.
Good to know
Play/pause is a toggle, not a pause: if playback was already stopped, it starts
again. Leaving Act only while audio is playing on keeps it honest, and the
Windows disconnect sound is not counted as playback.
The mute action applies to whichever device is the default after the switch,
which is normally the internal speakers. Pair When a device connects with
unmute if the headset should bring the sound back when it returns.
The mod runs in a small process of its own rather than inside Explorer, and uses
the Windows Core Audio API. The notification callback only wakes a worker thread;
the delay, the playback check and the media key all happen there.