From 64aa53ab246949773fad0ccef06a6b13702ef45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 15 Aug 2021 13:33:49 +0200 Subject: [PATCH] Correctly handle media errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The methods need to be async since play() is async, otherwise there is no point in having the try catch blocks Signed-off-by: Šimon Brandner --- src/components/views/voip/AudioFeed.tsx | 4 ++-- src/components/views/voip/VideoFeed.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/voip/AudioFeed.tsx b/src/components/views/voip/AudioFeed.tsx index 3049d80c727..d6d1261343f 100644 --- a/src/components/views/voip/AudioFeed.tsx +++ b/src/components/views/voip/AudioFeed.tsx @@ -72,7 +72,7 @@ export default class AudioFeed extends React.Component { } }; - private playMedia() { + private async playMedia() { const element = this.element.current; if (!element) return; this.onAudioOutputChanged(MediaDeviceHandler.getAudioOutput()); @@ -90,7 +90,7 @@ export default class AudioFeed extends React.Component { // should serialise the ones that need to be serialised but then be able to interrupt // them with another load() which will cancel the pending one, but since we don't call // load() explicitly, it shouldn't be a problem. - Dave - element.play(); + await element.load(); } catch (e) { logger.info("Failed to play media element with feed", this.props.feed, e); } diff --git a/src/components/views/voip/VideoFeed.tsx b/src/components/views/voip/VideoFeed.tsx index 1430a7974a9..4607b750eba 100644 --- a/src/components/views/voip/VideoFeed.tsx +++ b/src/components/views/voip/VideoFeed.tsx @@ -112,7 +112,7 @@ export default class VideoFeed extends React.PureComponent { } } - private playMedia() { + private async playMedia() { const element = this.element; if (!element) return; // We play audio in AudioFeed, not here @@ -129,7 +129,7 @@ export default class VideoFeed extends React.PureComponent { // should serialise the ones that need to be serialised but then be able to interrupt // them with another load() which will cancel the pending one, but since we don't call // load() explicitly, it shouldn't be a problem. - Dave - element.play(); + await element.play(); } catch (e) { logger.info("Failed to play media element with feed", this.props.feed, e); }