From d95c53ed24a247ec0bc3c4268887206c1c66698a Mon Sep 17 00:00:00 2001 From: or-else Date: Sun, 26 Jun 2022 19:29:11 -0700 Subject: [PATCH] add catch() to play(), otherwise it throws --- src/widgets/call-incoming.jsx | 5 +++-- src/widgets/call-panel.jsx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/widgets/call-incoming.jsx b/src/widgets/call-incoming.jsx index c4b8403e..59d126ad 100644 --- a/src/widgets/call-incoming.jsx +++ b/src/widgets/call-incoming.jsx @@ -39,8 +39,9 @@ export default class CallIncoming extends React.Component { this.resetDesc(topic, this.props); if (this.props.callState == CALL_STATE_INCOMING_RECEIVED) { - RING_SOUND.play(); - this.ringTimer = setInterval(() => RING_SOUND.play(), 2000); + // play() throws if the user did not click the app first: https://goo.gl/xX8pDD. + RING_SOUND.play().catch(_ => {}); + this.ringTimer = setInterval(_ => {RING_SOUND.play().catch(_ => {})}, 2000); this.props.onRinging(this.props.topic, this.props.seq); } } diff --git a/src/widgets/call-panel.jsx b/src/widgets/call-panel.jsx index d4a86f3a..c78d0228 100644 --- a/src/widgets/call-panel.jsx +++ b/src/widgets/call-panel.jsx @@ -121,7 +121,8 @@ class CallPanel extends React.PureComponent { this.handleVideoOfferMsg(info); break; case 'ringing': - RING_SOUND.play(); + // play() throws if the user did not click the app first: https://goo.gl/xX8pDD. + RING_SOUND.play().catch(_ => {}); break; default: console.warn("Unknown call event", info.event); @@ -336,7 +337,7 @@ class CallPanel extends React.PureComponent { RING_SOUND.pause(); RING_SOUND.currentTime = 0; CALL_ENDED_SOUND.loop = true; - CALL_ENDED_SOUND.play(); + CALL_ENDED_SOUND.play().catch(_ => {}); setTimeout(_ => { this.handleCloseClick(); }, 2000);