AbedElazizShe / LightCompressor

A powerful and easy-to-use video compression library for android uses MediaCodec API.
Apache License 2.0
518 stars 117 forks source link

Primary directory download not allowed for content://media/external_primary/video/media; allowed directories are DCIM, Movies Pictures #112

Closed Shruthi18041991 closed 2 years ago

Shruthi18041991 commented 2 years ago

VideoCompressor.start( this, // => This is required uris, // => Source can be provided as content uris true, // => isStreamable Environment.DIRECTORY_DOWNLOADS, // => the directory to save the compressed video(s) new CompressionListener() { @Override public void onSuccess(int i, long l, @Nullable String s) {

            runOnUiThread(new Runnable() {
                public void run() {
                    ProgressDialogHelper.dismiss();

                }
            });
        }

        @Override
        public void onStart(int i) {

        }

        @Override
        public void onFailure(int index, String failureMessage) {
            // On Failure
        }

        @Override
        public void onProgress(int index, float progressPercent) {
            // Update UI with progress value
            runOnUiThread(new Runnable() {
                public void run() {
                    ProgressDialogHelper.showProgressDialogWithProgress(context, "Compressing ...." + Math.round(progressPercent) + "%");

                }
            });
        }

        @Override
        public void onCancelled(int index) {
            // On Cancelled
        }
    }, new Configuration(
            VideoQuality.MEDIUM,
            24, /*frameRate: int, or null*/
            false, /*isMinBitrateCheckEnabled*/
            null, /*videoBitrate: int, or null*/
            false, /*disableAudio: Boolean, or null*/
            false, /*keepOriginalResolution: Boolean, or null*/
            360.0, /*videoWidth: Double, or null*/
            480.0 /*videoHeight: Double, or null*/
    )

);

When I try to compress a video with above configuration , the app crashed with the error (as mentioned in the title). Device - Samsung Galaxy A50 Android version-11

Andoctorey commented 2 years ago

Have the same issue when try to save in ContextCompat.getExternalFilesDirs(context, null) without storage permission. Previous version 1.0.1 worked without problem.

EbelloImbox commented 2 years ago

It was working in previous version for me too, but it is not working with the last version and it is not working in Android 13 neither.