From 53ea6f802419b1db6f0c6d444cd9707be003affc Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Fri, 10 Sep 2021 13:35:55 +0000 Subject: [PATCH] [FIX] mail: load audio/video elements after changing the srcObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, there could be tracebacks after changing the srcObject of the audioElement of the rtcSession, this commit fixes this issue by calling `load` on the element after changing the srcObject. closes odoo/odoo#76422 X-original-commit: ec3aa0ef713cc0f048dbf6f5a36c86448a411baa Signed-off-by: Sébastien Theys (seb) --- addons/mail/static/src/components/rtc_video/rtc_video.js | 5 +++-- addons/mail/static/src/models/rtc_session/rtc_session.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/components/rtc_video/rtc_video.js b/addons/mail/static/src/components/rtc_video/rtc_video.js index 185669d651f..5c1f2b8369f 100644 --- a/addons/mail/static/src/components/rtc_video/rtc_video.js +++ b/addons/mail/static/src/components/rtc_video/rtc_video.js @@ -50,9 +50,10 @@ export class RtcVideo extends Component { } if (!this.rtcSession || !this.rtcSession.videoStream) { this._videoRef.el.srcObject = undefined; - return; + } else { + this._videoRef.el.srcObject = this.rtcSession.videoStream; } - this._videoRef.el.srcObject = this.rtcSession.videoStream; + this._videoRef.el.load(); } //-------------------------------------------------------------------------- diff --git a/addons/mail/static/src/models/rtc_session/rtc_session.js b/addons/mail/static/src/models/rtc_session/rtc_session.js index 5a11c625a4f..8ca7e95fb10 100644 --- a/addons/mail/static/src/models/rtc_session/rtc_session.js +++ b/addons/mail/static/src/models/rtc_session/rtc_session.js @@ -108,6 +108,7 @@ function factory(dependencies) { this._removeAudio(); const audioElement = this.audioElement || new window.Audio(); audioElement.srcObject = audioStream; + audioElement.load(); audioElement.volume = this.partner && this.partner.volumeSetting ? this.partner.volumeSetting.volume : this.volume; audioElement.muted = this.messaging.mailRtc.currentRtcSession.isDeaf; // Using both autoplay and play() as safari may prevent play() outside of user interactions