From 052cdb5fb011b8c32809f2c28e48e9a8727a4d80 Mon Sep 17 00:00:00 2001 From: gschian0 <54407820+gschian0@users.noreply.github.com> Date: Fri, 14 May 2021 14:02:11 -0400 Subject: [PATCH] resume audio context on first click for chrome --- webtools/src/Webtools.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webtools/src/Webtools.js b/webtools/src/Webtools.js index 729051d..ad317ab 100644 --- a/webtools/src/Webtools.js +++ b/webtools/src/Webtools.js @@ -8,6 +8,7 @@ import TableCell from "@material-ui/core/TableCell"; import TableRow from "@material-ui/core/TableRow"; import DashPlayer from "./DashPlayer"; +import { audioContext } from "./Video"; const STAT_URL = "/stat"; const NGINX_INFO_URL = "/nginxInfo"; @@ -95,6 +96,7 @@ export default class Webtools extends React.Component { selectedStream: null, serverInfo: null, statRetryTimer: 1, + windowClicked: false, }; } @@ -204,7 +206,17 @@ export default class Webtools extends React.Component { render() { const { selectedStream, serverInfo, streamNames } = this.state; return ( -
+
+ + { + // to resume audiocontext if the browser stops it + window.addEventListener('click', () => { + if(!this.state.windowClicked){ + audioContext.resume(); + console.log('clicked'); + this.setState({windowClicked: true}) + }}) + }