-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-mgmt-client
- Loading branch information
Showing
14 changed files
with
208 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import LinearProgress from '@mui/material/LinearProgress'; | ||
import { useContext, useEffect, useState } from 'react'; | ||
import { ServiceContext } from '../../store/store'; | ||
import { VolumeWatcher } from '../../utils/volumeWatcher'; | ||
import hark from 'hark'; | ||
|
||
const MicVolume = (): JSX.Element => { | ||
const { mediaService } = useContext(ServiceContext); | ||
const [ volumeLevel, setVolume ] = useState<number>(0); | ||
|
||
useEffect(() => { | ||
let volumeWatcher: VolumeWatcher | undefined; | ||
|
||
// Add hark for mic | ||
if (mediaService.previewMicTrack) { | ||
const harkStream = new MediaStream(); | ||
|
||
harkStream.addTrack(mediaService.previewMicTrack.clone()); | ||
|
||
const micHark = hark(harkStream, { | ||
play: false, | ||
interval: 100, | ||
threshold: -60, | ||
history: 100 | ||
}); | ||
|
||
volumeWatcher = new VolumeWatcher({ hark: micHark }); | ||
} | ||
|
||
const onVolumeChange = ({ scaledVolume }: { scaledVolume: number }): void => { | ||
setVolume(scaledVolume*10); // Range: 0-100 | ||
}; | ||
|
||
volumeWatcher?.on('volumeChange', onVolumeChange); | ||
|
||
return () => { | ||
volumeWatcher?.off('volumeChange', onVolumeChange); | ||
}; | ||
}, [ mediaService.previewMicTrack ]); | ||
|
||
return ( | ||
<LinearProgress color='success' variant="determinate" value={volumeLevel} /> | ||
); | ||
}; | ||
|
||
export default MicVolume; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.