You can completely disable the media OSD by using a small freeware application called HideVolumeOSD. This will prevent the OSD from appearing but will keep the media-buttons functionality (play, volume...).
On the other hand, Chromium-based browsers have started to allow the use of media-keys to control the playback. You can disable it, but it will completely remove the media-keys support: navigate to
about:flags and search for
media session, then disable the
Media Session Service and
Hardware Media Key Handling:
Some other applications may allow controlling it individually, like Spotify:
Menu > Edit > Preferences > (scroll down) Display options > Show desktop overlay when using media keys