I have a simple HTMLAudioElement element:

```
let player = new Audio()
player.src = 'file://' + _filePath
player.load()

```

This pauses and plays by using the play/pause media keys while the windows isn't focused,

**Q:** how do I make it ignore the play/pause keys?

I'm using electron but not sure if this is a chrome or electron implementation so I'm tagging both.
['https://Stackoverflow.com/questions/64814676', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5905035/']
Found an answer in this question: [Disable media control keys with javascript](https://stackoverflow.com/questions/59347480/disable-media-control-keys-with-javascript), thanks @PableWeb18

We can just override the media key listeners:

```
navigator.mediaSession.setActionHandler('play', function() { /* Code excerpted. */ });
navigator.mediaSession.setActionHandler('pause', function() { /* Code excerpted. */ });
navigator.mediaSession.setActionHandler('seekbackward', function() { /* Code excerpted. */ });
navigator.mediaSession.setActionHandler('seekforward', function() { /* Code excerpted. */ });
navigator.mediaSession.setActionHandler('previoustrack', function() { /* Code excerpted. */ });
navigator.mediaSession.setActionHandler('nexttrack', function() { /* Code excerpted. */ });

```
To override a function you can use `prototype`, see the example below:

```js
var audio = new Audio();
Audio.prototype.play = function() {
  console.log('Play override')
};
Audio.prototype.stop = function() {
  console.log('Stop override')
};
audio.play();
audio.stop();
```

`EDIT:`

So just add the primary function inside a var and after you done, put in together using prototype again:

```js
var audio = new Audio('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3');
var play = audio.play;
var pause = audio.pause;
Audio.prototype.play = function() {
  console.log('Nothing happened')
};
Audio.prototype.pause = function() {
  console.log('Nothing happened')
};
audio.play();
audio.pause();
Audio.prototype.play = play;
Audio.prototype.pause = pause;
audio.play();
setTimeout(function() { audio.pause() }, 5000)
```