Merge pull request #619 from robintown/unmute
Leave audio elements unmuted regardless of mute state
This commit is contained in:
commit
e9ebccf0df
1 changed files with 11 additions and 12 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useEffect, useRef } from "react";
|
import React, { FC, useEffect, useRef } from "react";
|
||||||
|
|
||||||
import { Participant } from "../room/InCallView";
|
import { Participant } from "../room/InCallView";
|
||||||
import { useCallFeed } from "./useCallFeed";
|
import { useCallFeed } from "./useCallFeed";
|
||||||
|
@ -29,19 +29,22 @@ interface AudioForParticipantProps {
|
||||||
audioDestination: AudioNode;
|
audioDestination: AudioNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AudioForParticipant({
|
export const AudioForParticipant: FC<AudioForParticipantProps> = ({
|
||||||
item,
|
item,
|
||||||
audioContext,
|
audioContext,
|
||||||
audioDestination,
|
audioDestination,
|
||||||
}: AudioForParticipantProps): JSX.Element {
|
}) => {
|
||||||
const { stream, localVolume, audioMuted } = useCallFeed(item.callFeed);
|
const { stream, localVolume } = useCallFeed(item.callFeed);
|
||||||
const [audioTrackCount] = useMediaStreamTrackCount(stream);
|
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 && audioTrackCount > 0) {
|
// We don't compare the audioMuted flag of useCallFeed here, since unmuting
|
||||||
|
// depends on to-device messages which may lag behind the audio actually
|
||||||
|
// starting to flow over the network
|
||||||
|
if (!item.isLocal && audioContext && audioTrackCount > 0) {
|
||||||
if (!gainNodeRef.current) {
|
if (!gainNodeRef.current) {
|
||||||
gainNodeRef.current = new GainNode(audioContext, {
|
gainNodeRef.current = new GainNode(audioContext, {
|
||||||
gain: localVolume,
|
gain: localVolume,
|
||||||
|
@ -68,12 +71,11 @@ export function AudioForParticipant({
|
||||||
audioDestination,
|
audioDestination,
|
||||||
stream,
|
stream,
|
||||||
localVolume,
|
localVolume,
|
||||||
audioMuted,
|
|
||||||
audioTrackCount,
|
audioTrackCount,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
interface AudioContainerProps {
|
interface AudioContainerProps {
|
||||||
items: Participant[];
|
items: Participant[];
|
||||||
|
@ -81,10 +83,7 @@ interface AudioContainerProps {
|
||||||
audioDestination: AudioNode;
|
audioDestination: AudioNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AudioContainer({
|
export const AudioContainer: FC<AudioContainerProps> = ({ items, ...rest }) => {
|
||||||
items,
|
|
||||||
...rest
|
|
||||||
}: AudioContainerProps): JSX.Element {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{items
|
{items
|
||||||
|
@ -94,4 +93,4 @@ export function AudioContainer({
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue