diff --git a/android/src/main/java/com/opentokreactnative/OTRNPublisher.kt b/android/src/main/java/com/opentokreactnative/OTRNPublisher.kt index 08fef188..e48e3152 100644 --- a/android/src/main/java/com/opentokreactnative/OTRNPublisher.kt +++ b/android/src/main/java/com/opentokreactnative/OTRNPublisher.kt @@ -243,18 +243,21 @@ class OTRNPublisher : FrameLayout, PublisherListener, .enableOpusDtx(this.props?.get("enableDtx") as Boolean) .build() publisher?.setPublisherVideoType(PublisherKit.PublisherKitVideoType.PublisherKitVideoTypeCamera) - if (this.props?.get("cameraPosition") == "back") { - publisher?.cycleCamera() - } if (this.props?.get("videoTrack") as Boolean) { publisher?.getCapturer()?.setVideoContentHint( Utils.convertVideoContentHint(this.props?.get("videoContentHint") as String) ) } + if (this.props?.get("cameraPosition") as String == "back") { + // Do not set publishVideo here, start when stream is created + // to avoid front camera preview flash + publisher?.setPublishVideo(false) + } else { + publisher?.setPublishVideo(this.props?.get("publishVideo") as Boolean) + } } publisher?.setPublishAudio(this.props?.get("publishAudio") as Boolean) - publisher?.setPublishVideo(this.props?.get("publishVideo") as Boolean) publisher?.setPublishCaptions(this.props?.get("publishCaptions") as Boolean) publisher?.setStyle( BaseVideoRenderer.STYLE_VIDEO_SCALE, @@ -295,10 +298,14 @@ class OTRNPublisher : FrameLayout, PublisherListener, this.addView(publisher?.view) requestLayout() } - props!!.clear() //we do not need to keep this around ? } override fun onStreamCreated(publisher: PublisherKit, stream: Stream) { + val cameraPosition = this.props?.get("cameraPosition") as? String ?: "front" + if (cameraPosition == "back") { + this.publisher?.cycleCamera() + this.publisher?.setPublishVideo(this.props?.get("publishVideo") as Boolean) + } val payload = EventUtils.prepareJSStreamMap(stream, publisher.getSession()) emitOpenTokEvent("onStreamCreated", payload) }