Harmeet Singh
Harmeet Singh

Reputation: 67

Capture Screenshots on button click from Youtube Player Android

Is there any possible way to capture video frames on button click from Youtube Player? Or Youtube player does not allow this?

Below code gives image with black screen:

rootView.setDrawingCacheEnabled(true);
rootView.buildDrawingCache(true);          
FileOutputStream fileOutputStream = new FileOutputStream(imagePath);
rootView.getDrawingCache(true).compress(CompressFormat.JPEG, 100,
               fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
rootView.setDrawingCacheEnabled(false);

Upvotes: 1

Views: 404

Answers (1)

Sebastiano
Sebastiano

Reputation: 12339

As it has been said here, children of SurfaceView are typically hardware accelerated and thus do not use the standard view hierarchy system.

The YouTube SDK most likely uses this object to display the video, and that is why your code is not working.

Upvotes: 1

Related Questions