diff --git a/src/components/Permissions.js b/src/components/Permissions.js new file mode 100644 index 0000000..304f72f --- /dev/null +++ b/src/components/Permissions.js @@ -0,0 +1,81 @@ +import React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import Modal from '@material-ui/core/Modal'; +import Backdrop from '@material-ui/core/Backdrop'; +import Fade from '@material-ui/core/Fade'; +import Typography from '@material-ui/core/Typography'; + +const useStyles = makeStyles(theme => ({ + modal: { + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }, + paper: { + backgroundColor: theme.palette.background.paper, + border: '2px solid #000', + boxShadow: theme.shadows[5], + padding: theme.spacing(2, 4, 3), + }, +})); + +export default function TransitionsModal() { + const classes = useStyles(); + const [open, setOpen] = React.useState(false); + + React.useEffect(() => { + if(!navigator || !navigator.mediaDevices) { + console.warn("Could not detect media devices. This may be because the application was not loaded over a secure context (e.g. https). https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Security"); + setOpen(true); + + return; + } + + navigator.mediaDevices.getUserMedia({ audio: true }) + .then(() => { + setOpen(false); + }) + .catch(() => { + setOpen(true); + }) + ; + + return () => {}; + }); + + const handleOpen = () => { + setOpen(true); + }; + + const handleClose = () => { + setOpen(false); + }; + + return ( +
+ + +
+ + This application requires access to your microphone. + + + + +
+
+
+
+ ); +} diff --git a/src/components/layout/AppViewport.js b/src/components/layout/AppViewport.js index 51de573..704e37b 100644 --- a/src/components/layout/AppViewport.js +++ b/src/components/layout/AppViewport.js @@ -2,6 +2,8 @@ import React from 'react'; import Box from '@material-ui/core/Box'; +import Permissions from '../Permissions'; + import TopBar from './TopBar'; import MyBox from '../MyBox/MyBox'; @@ -11,6 +13,7 @@ export default function AppViewport() { + ); };