Code Monkey home page Code Monkey logo

Comments (4)

timmydoza avatar timmydoza commented on June 12, 2024

Thanks for the issue @praveshkhatana! Glad you could get this working on iOS.

Could you please provide a more complete complete code example? A link to a fork would be nice. It's difficult to figure out what the issue is without more context. I'd also be interested in how you got it working on iOS.

Thanks!

from twilio-video-app-react.

bhargavgoli avatar bhargavgoli commented on June 12, 2024

Hey @timmydoza Hope you doing great.

I was trying to modify the userLocalVideoTrack hook to flip the camera.

I have the same issue. Please find the below code.

`export function useLocalVideoTrack() {
const [track, setTrack] = useState();
const camFacing: CameraFacing = CAMERA === 'Front' ? 'Back' : 'Front';
const [cameraFacing, setCameraFacing] = useState(camFacing);

const getLocalVideoTrack = useCallback(
    async () => {


        const permissions = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
        const devices = await navigator.mediaDevices.enumerateDevices();
        const videoDevices = devices.filter(d => d.kind === 'videoinput');
        let videoPermissions = videoDevices.length > 1 && (CAMERA === 'Back' || CAMERA === null) ? {facingMode: 'user'} : {facingMode: 'environment'};


        if (CAMERA === null) {
            CAMERA = camFacing;
        } else {
            // alert(camFacing);
            const camF = CAMERA !== 'Front' ? 'Front' : 'Back';
            setCameraFacing(camF);
            CAMERA = camF;
        }

        return Video.createLocalVideoTrack({
            frameRate: 24,
            height: 480,
            width: 720,
            facingMode: videoPermissions.facingMode,
            name: 'camera'
        }).then(newTrack => {
            setTrack(newTrack);
            return newTrack;
        });
    },
    []
);

useEffect(() => {
    // We get a new local video track when the app loads.
    getLocalVideoTrack();
}, [getLocalVideoTrack]);

useEffect(() => {
    const handleStopped = () => setTrack(undefined);
    if (track) {
        track.on('stopped', handleStopped);
        return () => {
            track.off('stopped', handleStopped);
        };
    }
}, [track]);

return [track, getLocalVideoTrack, cameraFacing] as const;}

`
The above code is working perfect with IOS, but not on android phones.

from twilio-video-app-react.

bhargavgoli avatar bhargavgoli commented on June 12, 2024

Hey @timmydoza

I got fixed.

Thanks.

from twilio-video-app-react.

timmydoza avatar timmydoza commented on June 12, 2024

@praveshkhatana @bhargavgoli
We just added this feature to the master branch of our app. If you are interested, you can see changes in the PR here: #152

from twilio-video-app-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.