opentok-react-native
opentok-react-native copied to clipboard
cameraPosition not working
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)
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
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
the issues is still there, any update?
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
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?