twilio / twilio-video-app-react

A collaboration application built with the twilio-video.js SDK and React.js
Apache License 2.0
1.8k stars 725 forks source link

It's possible catch event when user changed facingMode? #760

Closed AndreyPatseiko closed 1 year ago

AndreyPatseiko commented 1 year ago

Question It's possible catch event when user changed facingMode?

I have application where is critical part to display video from same direction. In your examples you mirrored local image when user switch facingMode

VideoTrack.tsx

const isFrontFacing = mediaStreamTrack?.getSettings().facingMode !== 'environment';
  const style = {
    transform: isLocal && isFrontFacing ? 'scaleX(-1)' : '',
    objectFit: isPortrait || track.name.includes('screen') ? ('contain' as const) : ('cover' as const),
  };

But how I can check that participant switched facingMode in not localTrack?

manjeshbhargav commented 1 year ago

@AndreyPatseiko ,

I think you can write a React hook that listens to the "started" event on the local video track, and checks the constraints passed to the "restart()" method. Hope this answers your question.