Check for audio track count
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
fd8ade1bf1
commit
897f127fbd
1 changed files with 3 additions and 1 deletions
|
@ -18,6 +18,7 @@ import React, { useEffect, useRef } from "react";
|
||||||
|
|
||||||
import { Participant } from "../room/InCallView";
|
import { Participant } from "../room/InCallView";
|
||||||
import { useCallFeed } from "./useCallFeed";
|
import { useCallFeed } from "./useCallFeed";
|
||||||
|
import { useMediaStreamTrackCount } from "./useMediaStream";
|
||||||
|
|
||||||
// XXX: These in fact do not render anything but to my knowledge this is the
|
// XXX: These in fact do not render anything but to my knowledge this is the
|
||||||
// only way to a hook on an array
|
// only way to a hook on an array
|
||||||
|
@ -34,12 +35,13 @@ export function AudioForParticipant({
|
||||||
audioDestination,
|
audioDestination,
|
||||||
}: AudioForParticipantProps): JSX.Element {
|
}: AudioForParticipantProps): JSX.Element {
|
||||||
const { stream, localVolume, audioMuted } = useCallFeed(item.callFeed);
|
const { stream, localVolume, audioMuted } = useCallFeed(item.callFeed);
|
||||||
|
const [audioTrackCount] = useMediaStreamTrackCount(stream);
|
||||||
|
|
||||||
const gainNodeRef = useRef<GainNode>();
|
const gainNodeRef = useRef<GainNode>();
|
||||||
const sourceRef = useRef<MediaStreamAudioSourceNode>();
|
const sourceRef = useRef<MediaStreamAudioSourceNode>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!item.isLocal && audioContext && !audioMuted) {
|
if (!item.isLocal && audioContext && !audioMuted && audioTrackCount > 0) {
|
||||||
if (!gainNodeRef.current) {
|
if (!gainNodeRef.current) {
|
||||||
gainNodeRef.current = new GainNode(audioContext, {
|
gainNodeRef.current = new GainNode(audioContext, {
|
||||||
gain: localVolume,
|
gain: localVolume,
|
||||||
|
|
Loading…
Reference in a new issue