From 66c5812b4e1e696cff31013890a492ade6b0d48b Mon Sep 17 00:00:00 2001 From: Mariusz Marciniak Date: Tue, 2 Nov 2021 21:46:51 +0100 Subject: [PATCH] KASM-2034 Unlock mobile audio playing on first mobile touch event --- core/rfb.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/rfb.js b/core/rfb.js index ba1d72f8..7fc5388f 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -960,6 +960,15 @@ export default class RFB extends EventTargetMixin { } _focusCanvas(event) { + // Hack: + // On most mobile phones it's only possible to play audio + // only if it's triggered by a user action. Moreover, since it's also + // impossible to listen for touch events on child frames (only on mobile phones) + // we delegate the audio unlocking to the parent window. + if (window.parent && !window.parent.KASM_AUDIO_UNLOCKED) { + window.parent.unlockAudio(); + } + if (!this.focusOnClick) { return; }