Reputation: 9
I'm using ExoPlayer which show captured videos , but when front_camera is captured a video , display as flipped .
I've tried to do flip the exoplayerView exoPlayerView.scaleX= -1f
private fun videoPlayingMode() {
capturedImageView.visibility = View.GONE
exoPlayerView.visibility = View.VISIBLE
//exoPlayerView.scaleX= -1f
}
I've also implement flip function to convert captured image to flip but I could not implement this for captured video .
private fun flip(src: Bitmap): Bitmap {
// create new matrix for transformation
val matrix = Matrix()
matrix.preScale(-1.0f, 1.0f)
// return transformed image
return Bitmap.createBitmap(src, 0, 0, src.width, src.height, matrix, true)
}
I expect the when capture a video with front camera , video should not be flipped. Note: I've also using CameraKit library and I'm not using TextureView
Upvotes: 0
Views: 1268
Reputation: 182
As i tried below way is worked as well and the front camera's recorded video can be shown mirrored(flip) in exoplayer:
First: add app:surface_type="texture_view" to your exo player view like below:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoPlayerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
...
**app:surface_type="texture_view"**
... />
Second: get the videoSurfaceView from exoPlayerView and set scale to -1 like below:
binding.exoPlayerView.apply {
**videoSurfaceView?.scaleX = -1f**
}
Upvotes: 3
Reputation: 9
I found the solution and implement it.Problem Solved.
fun loadVideo(videoUri: Uri) {
if (camera?.facing == CameraKit.Constants.FACING_FRONT) {
exoPlayerView.scaleY = -1f
}
Upvotes: 0