Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Url returned for Android 9 and lower is wrong #183

Open
akrulec opened this issue Dec 7, 2023 · 1 comment
Open

Url returned for Android 9 and lower is wrong #183

akrulec opened this issue Dec 7, 2023 · 1 comment

Comments

@akrulec
Copy link

akrulec commented Dec 7, 2023

This is how I use the video compressor:

VideoCompressor.start(
                context = CoPilotApplication.application.applicationContext,
                uris = listOf(uri),
                isStreamable = true,
                sharedStorageConfiguration =
                    SharedStorageConfiguration(
                        saveAt = SaveLocation.movies, // => default is movies
                    ),
                configureWith =
                    Configuration(
                        quality = VideoQuality.LOW,
                        isMinBitrateCheckEnabled = false,
                        // This needs to be different every time.
                        videoNames = listOf(UUID.randomUUID().toString())),
                listener =
                    object : CompressionListener {
                        override fun onProgress(index: Int, percent: Float) {
                            // Nothing
                        }

                        override fun onStart(index: Int) {
                            // Nothing really.
                        }

                        override fun onSuccess(index: Int, size: Long, path: String?) {
                            Timber.d("File compressed successfully: $path, $size")
                            // Upload video.
                            analyticsRepository.logEvent(Event.Chat.VIDEO_SENT, null)
                            path?.let { addMediaViewModel.uploadVideo(File(path)) }
                        }

                        override fun onFailure(index: Int, failureMessage: String) {
                            Timber.e(failureMessage)
                            addMediaViewModel.error()
                        }

                        override fun onCancelled(index: Int) {
                            // Make UI changes, cleanup, etc.
                            Timber.e("compression has been cancelled")
                            addMediaViewModel.error()
                        }
                    },
            )

When I added some print statements, I tell video compressor the video should be called 30758f51-8e0a-449c-a421-2268cd3953c1. It says, I've compressed video, and it's here /storage/emulated/0/Movies/30758f51-8e0a-449c-a421-2268cd3953c1_temp.mp4, but there is no such file there, it's /storage/emulated/0/Movies/30758f51-8e0a-449c-a421-2268cd3953c1.mp4 . I'm using version com.github.AbedElazizShe:LightCompressor:1.3.2 . Is this intended? How do I get around this?

@keyur-Dev
Copy link

keyur-Dev commented Jan 24, 2024

Hey @akrulec , I met with the same issue while using this library. I investigated some parts and found that if we give isStreamable=true, it adds _temp to the file name we have given. I just changed it to false and it worked perfectly. (I am using android 13 on my device)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants