0

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

BrkBrkBrk
  • 9
  • 2

3 Answers3

1

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**
        }
hkh114
  • 162
  • 1
  • 3
  • 15
0

You can rotate view:

VideoView.setRotation(180);
Shadkirill
  • 92
  • 6
  • thank you for your suggestion but this not a rotation problem , it's a mirror issue just like this https://stackoverflow.com/questions/50680830/android-video-mirror-effect – BrkBrkBrk Sep 23 '19 at 13:21
0

I found the solution and implement it.Problem Solved.

fun loadVideo(videoUri: Uri) {
    if (camera?.facing == CameraKit.Constants.FACING_FRONT) {
        exoPlayerView.scaleY = -1f
    } 
BrkBrkBrk
  • 9
  • 2