Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: audio level visualiser #2747

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { useMedia } from 'react-use';
import {
DeviceType,
selectIsLocalVideoEnabled,
selectLocalPeerID,
selectLocalVideoTrackID,
selectPeerAudioByID,
selectVideoTrackByID,
useDevices,
useHMSActions,
Expand All @@ -29,6 +31,8 @@ const Settings = ({ setHide }) => {
const { videoInput, audioInput, audioOutput } = allDevices;
const videoTrackId = useHMSStore(selectLocalVideoTrackID);
const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
const localPeerID = useHMSStore(selectLocalPeerID);
const localAudioLevel = useHMSStore(selectPeerAudioByID(localPeerID));
// don't show speaker selector where the API is not supported, and use
// a generic word("Audio") for Mic. In some cases(Chrome Android for example) this changes both mic and speaker keeping them in sync.
const shouldShowAudioOutput = 'setSinkId' in HTMLMediaElement.prototype;
Expand Down Expand Up @@ -85,6 +89,10 @@ const Settings = ({ setHide }) => {
</Fragment>
) : null}

<Box css={{ w: '100%', r: '$2', overflow: 'hidden', bg: '$surface_brighter', mb: '$2' }}>
<Flex css={{ w: `${localAudioLevel}%`, transition: 'width 50ms ease', bg: '$alert_success', h: '$3' }} />
</Box>

{audioInput?.length ? (
<DeviceSelector
title={shouldShowAudioOutput ? 'Microphone' : 'Audio'}
Expand Down
Loading