From 5c6ef10c6b6c1f063e9eeee653cc8419ff172200 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 21 Nov 2019 15:55:30 +0000 Subject: [PATCH 1/2] Ignore media actions Hopefully the comment explains all Fixes https://github.com/vector-im/riot-web/issues/11118 --- src/CallHandler.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/CallHandler.js b/src/CallHandler.js index 625ca8c551..4ffc9fb7a2 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -495,6 +495,15 @@ async function _startCallApp(roomId, type) { // with the dispatcher once if (!global.mxCallHandler) { dis.register(_onAction); + // add empty handlers for media actions, otherwise the media keys + // end up causing the audio elements with our ring/ringback etc + // audio clips in to play. + navigator.mediaSession.setActionHandler('play', function() {}); + navigator.mediaSession.setActionHandler('pause', function() {}); + navigator.mediaSession.setActionHandler('seekbackward', function() {}); + navigator.mediaSession.setActionHandler('seekforward', function() {}); + navigator.mediaSession.setActionHandler('previoustrack', function() {}); + navigator.mediaSession.setActionHandler('nexttrack', function() {}); } const callHandler = { From f0fbb20ee50b8d822175207136d8ffa3f1ee107c Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 21 Nov 2019 16:11:42 +0000 Subject: [PATCH 2/2] Detect support for mediaSession Firefox doesn't support mediaSession so don't try setting handlers --- src/CallHandler.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 4ffc9fb7a2..9350fe4dd9 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -498,12 +498,14 @@ if (!global.mxCallHandler) { // add empty handlers for media actions, otherwise the media keys // end up causing the audio elements with our ring/ringback etc // audio clips in to play. - navigator.mediaSession.setActionHandler('play', function() {}); - navigator.mediaSession.setActionHandler('pause', function() {}); - navigator.mediaSession.setActionHandler('seekbackward', function() {}); - navigator.mediaSession.setActionHandler('seekforward', function() {}); - navigator.mediaSession.setActionHandler('previoustrack', function() {}); - navigator.mediaSession.setActionHandler('nexttrack', function() {}); + if (navigator.mediaSession) { + navigator.mediaSession.setActionHandler('play', function() {}); + navigator.mediaSession.setActionHandler('pause', function() {}); + navigator.mediaSession.setActionHandler('seekbackward', function() {}); + navigator.mediaSession.setActionHandler('seekforward', function() {}); + navigator.mediaSession.setActionHandler('previoustrack', function() {}); + navigator.mediaSession.setActionHandler('nexttrack', function() {}); + } } const callHandler = {