Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions android/src/main/java/com/opentokreactnative/OTRNPublisher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to put back and front in some case of string literal, constant etc?

this.publisher?.cycleCamera()
this.publisher?.setPublishVideo(this.props?.get("publishVideo") as Boolean)
}
val payload = EventUtils.prepareJSStreamMap(stream, publisher.getSession())
emitOpenTokEvent("onStreamCreated", payload)
}
Expand Down