Skip to content

Add an option to ignore media button presses when a headset is inserted

NyanCatTW1 requested to merge NyanCatTW1/vlc-android:master into master


An option has been added under Audio/Headset, which looks like this:

Ignore headset media button presses  
In the case of a Bluetooth headset, all media button events will be ignored, which breaks the Media Control UI

When the option is enabled, the following occurs:

  1. When a wired headset is inserted, its media button events should be ignored
  2. When a Bluetooth headset is inserted, all media button events are ignored. This is because KeyEvent from a Bluetooth headset is identical to that of Media Control UI. Ignoring all events make the Media Control UI buttons useless, hence the notice in the option.

Motivation and Context

I own a headset with broken physical buttons. Every day or two, it will start spamming next track/previous track button presses. Needless to say, such a glitch makes the player unusable whenever it occurs.
Unfortunately, on Android, there is no way to disable media buttons globally without rooting the phone or physically blocking the pin (which also disables the mic). This means I need the option to make the player ignore those presses.

How Has This Been Tested?

Environment: Redmi note 7 + Android 10
I tried a random wired headset I can find at home, and the code successfully detected+ignored the events.
I also tried pairing a Bluetooth earphone to the phone. Once paired, the buttons on the earphone don't work, as expected. However, the pause/track buttons in the Media Control UI no longer works. This is a issue that I currently don't have a solution to.
To be clear, the Media Control UI breaks only if this option is enabled and a Bluetooth headset is paired.

Once I turn off the option, buttons on the headsets return to functionality, and having a Bluetooth headset paired no longer breaks the Media Control UI.

Todo (Help wanted)

  1. Test more wired/Bluetooth headsets to ensure the logic works across various devices
  2. Find a way to distinguish between Bluetooth headset button presses and Media Control UI events

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking change which cleans up / improves existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)


  • I have read the CONTRIBUTING section of the README document.


Fixes: #2771 (closed)

Edited by NyanCatTW1

Merge request reports