Skip to content

Commit

Permalink
Fix audio
Browse files Browse the repository at this point in the history
  • Loading branch information
huseyn0w committed Feb 8, 2021
1 parent 539e51b commit c3334b8
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions client/src/pages/Call/Streamer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ interface videoStreamInterface {
const Streamer:React.FC<videoStreamInterface> = ({stream, muted, fullName, controls=false}:videoStreamInterface) => {

const [videoMuted, setVideoMuted] = useState<Boolean>(false)
const [audioMuted, setAudioMuted] = useState<Boolean>(muted)
const [audioMuted, setAudioMuted] = useState<Boolean>(false)
const [showMuteIcon, setShowMuteIcon] = useState<Boolean>(false)
const videoEl = React.createRef<HTMLVideoElement>();


Expand All @@ -28,9 +29,7 @@ const Streamer:React.FC<videoStreamInterface> = ({stream, muted, fullName, contr
if(videoMuted) showVideo = false;
if(audioMuted) showAudio = false;

console.log(showAudio,showVideo)

stream.getVideoTracks()[0].enabled = showVideo;
stream.getVideoTracks()[0].enabled = showVideo
if(stream.getAudioTracks()[0]){
// console.log('hehey');
stream.getAudioTracks()[0].enabled = showAudio;
Expand All @@ -51,35 +50,27 @@ const Streamer:React.FC<videoStreamInterface> = ({stream, muted, fullName, contr

const audioHandler = () => {
setAudioMuted(!audioMuted);
setShowMuteIcon(!showMuteIcon)
}

const videoHandler = () => {
setVideoMuted(!videoMuted);

}




// console.log(streamKey)

let muteAudio = false;

if(muted){
muteAudio = true;
}

// console.log(muteAudio)

return (
<div className="stream-item">
<h2>Im {fullName}</h2>
<video ref={videoEl} muted={audioMuted ? true : false} autoPlay={true} />
<video ref={videoEl} muted={muted} autoPlay={true} />
{controls && (
<div className="stream-buttons">
<button type="button" onClick={audioHandler}>
{audioMuted ? <MicOffRoundedIcon /> : <MicRoundedIcon />}
</button>
{stream.getAudioTracks()[0] && (
<button type="button" onClick={audioHandler}>
{showMuteIcon ? <MicOffRoundedIcon /> : <MicRoundedIcon />}
</button>
)}

<button type="button" onClick={videoHandler}>
{videoMuted ? <VideocamOffRoundedIcon /> : <VideocamRoundedIcon />}
</button>
Expand Down

0 comments on commit c3334b8

Please sign in to comment.