import { Media, Peer, PeerControls, Video } from '@andyet/simplewebrtc'; import VolumeOffIcon from 'material-icons-svg/components/baseline/VolumeOff'; import VolumeUpIcon from 'material-icons-svg/components/baseline/VolumeUp'; import React, { useContext } from 'react'; import styled from 'styled-components'; import HiddenPeers from '../contexts/HiddenPeers'; import { TalkyButton } from '../styles/button'; import AudioOnlyPeer from './AudioOnlyPeer'; const MuteButton = styled(TalkyButton)({ display: 'inline-block', justifySelf: 'flex-end', opacity: 0.3, backgroundColor: 'black', color: 'white', transition: 'opacity 200ms linear', marginBottom: '16px', marginLeft: '16px', ':hover': { backgroundColor: 'black', opacity: 0.7 } }); const DisplayName = styled.span({ display: 'inline-block', backgroundColor: 'black', opacity: 0.3, color: 'white', marginTop: '16px', marginLeft: '16px', fontSize: '16px', padding: '2px 7px 2px 9px', borderRadius: '5px', transition: 'opacity 200ms linear', '&:hover': { cursor: 'pointer', opacity: 0.7 } }); const PictureInPictureContainer = styled.div({ position: 'relative', display: 'flex', justifyContent: 'center', alignItems: 'center', '& video:first-of-type': {}, '& video:last-of-type': { position: 'absolute', top: '16px', right: '16px', width: '100px' } }); interface PeerGridItemMediaProps { media: Media[]; } // PeerGridItemMedia renders a different visualization based on what media is // available from a peer. It will render video if the peer is sending video, // otherwise it renders an audio-only display. const PeerGridItemMedia: React.SFC = ({ media }) => { const videoStreams = media.filter( m => m.kind === 'video' && !m.remoteDisabled ); const audioStreams = media.filter(m => m.kind === 'audio'); if (videoStreams.length > 0) { // Choose last media as it is most likely the screenshare. const webcamStreams = videoStreams.filter(s => !s.screenCapture); const screenCaptureStreams = videoStreams.filter(s => s.screenCapture); if (videoStreams.length === 1) { return