camerakit-android icon indicating copy to clipboard operation
camerakit-android copied to clipboard

Video recording not getting store with android 11

Open SaggamAnand opened this issue 2 years ago • 0 comments

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

(Write your answer here.)

Environment

(Please include the following information along with any other relevant environment details.)

CameraKit Version: Tried with all the version

Android Device: One plus 6T Android Version: Android 11, API level:31, target SDK/compile SDK:31

Steps to Reproduce

(Write your steps here:)

  1. Setup the project with a camera kit, and started the capturing the video, able to capture video as well, but it is not getting stored on the local device because from Android 11 and with target SDK:31, we need to use the scoped storage (Just for reference: https://developer.android.com/about/versions/11/privacy/storage) Also google not allow to upload app on play store if target SDK not greater than 31.

  2. I would like to show the preview of the captured video, but as it's not getting stored in scope storage, not able to show the preview.

  3. I just go through went the Camera1.class (https://github.com/CameraKit/camerakit-android/blob/master/camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java) and what I found it we have not change the file storage to scope storage in private File getVideoFile() method. 4.Just paste the code for the reference: private File getVideoFile() { ``` if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null; }

     File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "Camera");
    
     if (!mediaStorageDir.exists()) {
         if (!mediaStorageDir.mkdirs()) {
             return null;
         }
     }
    
     return new File(mediaStorageDir.getPath() + File.separator + "video.mp4");
    

    }



### Expected Behavior

<!--
 should be able to capture video with android 11 and target SDK 31-->

(Write what you thought would happen.)

### Actual Behavior
Captured video is not getting saved. because with Android 11 device and target SDK 31, scope storage not implemented in Camare1.c
private File getVideoFile() {
        if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) {
            return null;
        }

        File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "Camera");

        if (!mediaStorageDir.exists()) {
            if (!mediaStorageDir.mkdirs()) {
                return null;
            }
        }

        return new File(mediaStorageDir.getPath() + File.separator + "video.mp4");
    }
(Write what happened. Add screenshots!)

### Reproducible Demo
https://developer.android.com/about/versions/11/privacy/storage
  Thanks for helping us help you!
-->

SaggamAnand avatar Apr 27 '22 16:04 SaggamAnand