Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cameraPosition not working #386

Open
simdanonline opened this issue Feb 22, 2020 · 5 comments
Open

cameraPosition not working #386

simdanonline opened this issue Feb 22, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@simdanonline
Copy link

simdanonline commented Feb 22, 2020

It still shows front camera, even though it is set to back
```

const [audio, setAudio] = useState(true)
const publisherProperties  = {
       publishAudio: audio,
        cameraPosition: 'back'

    };

const toggle = () => {
    if (audio) {
        setAudio(false);
    }
    else {
        setAudio(true)
    }

}




    <View style={styles.container}>
        <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', alignItems: 'flex-start' }} >
            <OTSession apiKey={apiKey} sessionId={sessionId} token={token} eventHandlers={sessionEventHandlers}>
                <OTPublisher style={{ width: 500, height: height }} properties={publisherProperties} />
            </OTSession>
        </View>
**Please post usage questions or broader discussions on [StackOverflow](https://stackoverflow.com/questions/ask?tags=opentok+react-native)**.

---

For **feature requests**, please fill out the [feature request template](https://github.com/opentok/opentok-react-native/issues/new?template=feature_request.md)

---

For **bug reports**, please fill out the [bug report issue template](https://github.com/opentok/opentok-react-native/issues/new?template=bug.md)
@enricop89
Copy link
Contributor

The correct options are facingMode: "environment" or "user". The former is the back one, the latter is the frontal one.

https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher

@LuuchoRocha
Copy link

LuuchoRocha commented Jun 18, 2021

I have the same issue. Is clear where the issue comes from:

android/src/main/java/com/opentokreactnative/OTSessionManager.java


    @ReactMethod
    public void initPublisher(String publisherId, ReadableMap properties, Callback callback) {

        String name = properties.getString("name");
        Boolean videoTrack = properties.getBoolean("videoTrack");
        Boolean audioTrack = properties.getBoolean("audioTrack");
        String cameraPosition = properties.getString("cameraPosition");
        Boolean audioFallbackEnabled = properties.getBoolean("audioFallbackEnabled");
        int audioBitrate = properties.getInt("audioBitrate");
        String frameRate = "FPS_" + properties.getInt("frameRate");
        String resolution = properties.getString("resolution");
        Boolean publishAudio = properties.getBoolean("publishAudio");
        Boolean publishVideo = properties.getBoolean("publishVideo");
        String videoSource = properties.getString("videoSource");
        Publisher mPublisher = null;
        if (videoSource.equals("screen")) {
            View view = getCurrentActivity().getWindow().getDecorView().getRootView();
            OTScreenCapturer capturer = new OTScreenCapturer(view);
            mPublisher = new Publisher.Builder(this.getReactApplicationContext())
                    .audioTrack(audioTrack)
                    .videoTrack(videoTrack)
                    .name(name)
                    .audioBitrate(audioBitrate)
                    .resolution(Publisher.CameraCaptureResolution.valueOf(resolution))
                    .frameRate(Publisher.CameraCaptureFrameRate.valueOf(frameRate))
                    .capturer(capturer)
                    .build();
            mPublisher.setPublisherVideoType(PublisherKit.PublisherKitVideoType.PublisherKitVideoTypeScreen);
        } else {
            mPublisher = new Publisher.Builder(this.getReactApplicationContext())
                    .audioTrack(audioTrack)
                    .videoTrack(videoTrack)
                    .name(name)
                    .audioBitrate(audioBitrate)
                    .resolution(Publisher.CameraCaptureResolution.valueOf(resolution))
                    .frameRate(Publisher.CameraCaptureFrameRate.valueOf(frameRate))
                    .build();
            if (cameraPosition.equals("back")) {
                mPublisher.cycleCamera();
            }
        }
        mPublisher.setPublisherListener(this);
        mPublisher.setAudioLevelListener(this);
        mPublisher.setAudioFallbackEnabled(audioFallbackEnabled);
        mPublisher.setPublishVideo(publishVideo);
        mPublisher.setPublishAudio(publishAudio);
        ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();
        mPublishers.put(publisherId, mPublisher);
        callback.invoke();
    }

As you can see:

            if (cameraPosition.equals("back")) {
                mPublisher.cycleCamera();
            }

The initPublisher method doesn't accept the facingMode parameter.

Using cameraPosition only triggers a cycleCamera() and will fail picking the correct camera if the device has more than two cameras.
I'm working in a PR

@radjivF
Copy link

radjivF commented Oct 14, 2021

the issues is still there, any update?

2021-10-14 at 11 38 AM

@enricop89
Copy link
Contributor

Thanks for reporting this. This is currently not supported at the native level so there is nothing we can do. I've already mentioned it to our Engineering team. I will leave this issue open for tracking purposes

@NAVEENCHVSPOP
Copy link

NAVEENCHVSPOP commented Mar 17, 2022

Thanks for reporting this. This is currently not supported at the native level so there is nothing we can do. I've already mentioned it to our Engineering team. I will leave this issue open for tracking purposes

@enricop89 Any update?

@abdulajet abdulajet added the enhancement New feature or request label May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants