Disable media keys


Is it possible to disable the media keys when using the Stream Player API?
Normally I would do the following but doesn’t seem like it’s working with the Cloudflare iframe:

if ('mediaSession' in navigator) {
  navigator.mediaSession.setActionHandler('play', () => { })
  navigator.mediaSession.setActionHandler('pause', () => { })
  navigator.mediaSession.setActionHandler('seekbackward', () => { })
  navigator.mediaSession.setActionHandler('seekforward', () => { })
  navigator.mediaSession.setActionHandler('previoustrack', () => { })
  navigator.mediaSession.setActionHandler('nexttrack', () => { })

Tried document.getElementById('iframe-element').contentWindow.mediaSession but getting Blocked a frame with origin "https://example.com" from accessing a cross-origin frame error.


We are showing the Cloudflare videos in a theater-style format and currently the viewers can pause and forward the video with their media keys which is kind of weird.
Also when you get an incoming phone call, the video pauses due to this.

Any quick solution for this?


Hi, when you say “media keys”, are you referring to the keyboard shortcuts that are built into the new Stream Player and if it is possible to disable them (by passing a flag etc.)?

Essentially I’m able to pause or seek the video through for example the Macbook Touch Bar keys, or when using a different keyboard the media keys are located elsewhere (if the keyboard has any).
The keys are not specific to the Cloudflare player, but normally you can disable them with navigator.mediaSession but since this is an iframe it doesn’t allow me to do that.
It would be great if I could pass a flag or send a iframe.contentWindow.postMessage or something to disable this behavior.