Instabug screenshot with exoplayer shows blank screen

2.3k views Asked by At

When take a screenshot from the exoplayer using Instabug bug reporting feature it shows blank screen although the video is working fine

screenshot example

3

There are 3 answers

0
Hossam Hassan On

Instabug doesn't support SurfaceView screenshot capturing at the time being, However, you can get the screenshot-capturing function work properly with the exoPlayer by changing the SurfaceType of the PlayerView to Texture_view instead of SurfaceView. You can do that using the following xml attribute.

app:surface_type="texture_view"

1
Ch Vas On

This depends on many factors, one of them is the content of the video itself. Take a look at this bug https://github.com/google/ExoPlayer/issues/1033

You can also try this Android Take Screenshot of Surface View Shows Black Screen

0
Tarun Anchala On

change surface type from SurfaceView to TextureView

 fun getScreenShotFromView(view: View, activity: Activity) {
    activity.window?.let { window ->
        val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
        val locationOfViewInWindow = IntArray(2)
        view.getLocationInWindow(locationOfViewInWindow)
        try {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                PixelCopy.request(
                    window,
                    Rect(
                        locationOfViewInWindow[0],
                        locationOfViewInWindow[1],
                        locationOfViewInWindow[0] + view.width,
                        locationOfViewInWindow[1] + view.height
                    ), bitmap, { copyResult ->
                        if (copyResult == PixelCopy.SUCCESS) {
                            callback(bitmap)                                
                        }
                    },
                    Handler()
                )
            }
        } catch (e: IllegalArgumentException) {
            // PixelCopy may throw IllegalArgumentException, make sure to handle it
            e.printStackTrace()
        }
    }
}

call method as below

getScreenShotFromView(binding.root,requireActivity())