Last active
March 19, 2021 23:57
-
-
Save kimberleehowley/af95575c61f21392cd8760641ace68b9 to your computer and use it in GitHub Desktop.
Passing saved audio tracks down to unique tile components in Daily video chat React app
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
// In Tile.js | |
export default function Tile(props) { | |
const videoEl = useRef(null); | |
const audioEl = useRef(null); | |
// ... | |
function getVideoComponent() { | |
return videoTrack && <video autoPlay muted playsInline ref={videoEl} />; | |
} | |
function getAudioComponent() { | |
return ( | |
!props.isLocalPerson && | |
audioTrack && <audio autoPlay playsInline ref={audioEl} /> | |
); | |
} | |
// ... | |
return ( | |
<div className={getClassNames()} onClick={props.onClick}> | |
<div className="background" /> | |
// ... | |
{getVideoComponent()} | |
{getAudioComponent()} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment