AbedElazizShe / LightCompressor

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

How to use it in a Android project based Jave? #107

Closed liwuchen closed 2 years ago

liwuchen commented 2 years ago

I have added this in build.gradle, but still can not use any method in my project. Does I need any other configrations?

implementation 'com.github.AbedElazizShe:LightCompressor:1.0.1'

gokhanaltun commented 2 years ago

I have this problem too.

I have added this in build.gradle, but still can not use any method in my project. Does I need any other configrations?

implementation 'com.github.AbedElazizShe:LightCompressor:1.0.1'

AbedElazizShe commented 2 years ago

Hi @liwuchen and @gokhanaltun what is the problem you're facing?

`VideoCompressor.start( getApplicationContext(), uri, null // src path, desFile.getPath(), null // streamablefile, new CompressionListener() { @Override public void onStart() {

                            }

                            @Override
                            public void onSuccess() {

                            }

                            @Override
                            public void onFailure(String message) {

                            }

                            @Override
                            public void onProgress(float percent) {

                            }

                            @Override
                            public void onCancelled() {

                            }
                        },
                        new Configuration(
                                VideoQuality.MEDIUM,
                                24, /*frameRate: int, or null*/
                                true, /*isMinBitrateCheckEnabled*/
                                3677198, /*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*/
                        ));`

Something like this should work.

gokhanaltun commented 2 years ago

Hi, @AbedElazizShe

Even though I added the dependency, I couldn't access the VideoCompressor class and realized that the problem was with my gradle files.

There was no "allprojects" section in my project-level build.gradle file and I was getting an error when I added it. To solve this problem I edited my "settings.gradle" file as below and now everything works. Thanks.

Before:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "Project Name"
include ':app'

After:

import org.gradle.api.initialization.resolve.RepositoriesMode

dependencyResolutionManagement {

    repositories {
        google()
        repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
        mavenCentral()
        maven { url 'https://jitpack.io' }
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "Project Name"
include ':app'
AbedElazizShe commented 2 years ago

Thank you @gokhanaltun I really forgot to add this part to README as i faced it myself after upgrading gradle. I added it now.