When take a screenshot from the exoplayer using Instabug bug reporting feature it shows blank screen although the video is working fine
Asked
Active
Viewed 2,229 times
3 Answers
2
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"

Hossam Hassan
- 665
- 1
- 8
- 22
2
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())

Tarun Anchala
- 2,232
- 16
- 15
0
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

Ch Vas
- 993
- 8
- 10
-
the screenshot works fine using the phone volume and power buttons. the problem happens when done with instabug – Ahmed Ali May 22 '18 at 19:53