Skip to content

Commit 629b4ef

Browse files
committed
- **Breaking** StorageConfiguration was removed.
- **Breaking** `AppSpecificStorageConfiguration` can be passed to store the output video in Android's App Specific Storage. - **Breaking** `SharedStorageConfiguration` can be passed to store the output video in Android's Primary Storage, it accepts storing at `pictures`, `downloads`, or `movies`. - Only one of the configurations can be provided at a time, either `AppSpecificStorageConfiguration` or `SharedStorageConfiguration`.
1 parent 044542f commit 629b4ef

File tree

6 files changed

+149
-125
lines changed

6 files changed

+149
-125
lines changed

README.md

Lines changed: 33 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ I would like to mention that the set attributes for size and quality worked just
1414

1515
**LightCompressor is now available in iOS**, have a look at [LightCompressor_iOS](https://github.com/AbedElazizShe/LightCompressor_iOS).
1616

17+
# Change Logs
18+
19+
## What's new in 1.2.3
20+
21+
- **Breaking** `StorageConfiguration` was removed.
22+
- **Breaking** `AppSpecificStorageConfiguration` can be passed to store the output video in Android's App Specific Storage.
23+
- **Breaking** `SharedStorageConfiguration` can be passed to store the output video in Android's Primary Storage, it accepts storing at `pictures`, `downloads`, or `movies`.
24+
- Only one of the configurations can be provided at a time, either `AppSpecificStorageConfiguration` or `SharedStorageConfiguration`.
25+
1726
# What's new in 1.2.2
1827

1928
- **Breaking** videoBitrate was renamed to videoBitrateInMbps. It should be int.
@@ -55,7 +64,7 @@ when {
5564
}
5665
```
5766

58-
You can as well pass custom videoHeight, videoWidth, frameRate, and videoBitrate values if you don't want the library to auto-generate the values for you. **The compression will fail if height or width is specified without the other, so ensure you pass both values**.
67+
You can as well pass custom videoHeight, videoWidth, and videoBitrate values if you don't want the library to auto-generate the values for you. **The compression will fail if height or width is specified without the other, so ensure you pass both values**.
5968

6069
These values were tested on a huge set of videos and worked fine and fast with them. They might be changed based on the project needs and expectations.
6170

@@ -107,7 +116,7 @@ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Version.coroutin
107116
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Version.coroutines}"
108117
```
109118

110-
Then just call [VideoCompressor.start()] and pass context, uris, isStreamable, storageConfiguration, and configureWith.
119+
Then just call [VideoCompressor.start()] and pass **context**, **uris**, **isStreamable**, **configureWith**, and either **sharedStorageConfiguration OR appSpecificStorageConfiguration**.
111120

112121
The method has a callback for 5 functions;
113122
1) OnStart - called when compression started
@@ -121,6 +130,7 @@ The method has a callback for 5 functions;
121130
- All the callback functions returns an index for the video being compressed in the same order of the urls passed to the library. You can use this index to update the UI
122131
or retrieve information about the original uri/file.
123132
- The source video must be provided as a list of content uris.
133+
- OnSuccess returns the path of the stored video.
124134
- If you want an output video that is optimised to be streamed, ensure you pass [isStreamable] flag is true.
125135

126136
### Configuration values
@@ -139,13 +149,18 @@ or retrieve information about the original uri/file.
139149

140150
- videoHeight: custom video height.
141151

142-
### Storage Configuration values
152+
### AppSpecificStorageConfiguration Configuration values
153+
154+
- videoName: a custom name for the output video.
155+
156+
- subFolderName: a subfolder name created in app's specific storage. The library won't create the subfolder and will throw an exception if the subfolder does not exist.
143157

144-
- fileName: a custom name for the output video. If ignored, the library will assign a name that is a combination of the video original name with a timestamp.
145158

146-
- isExternal: if passed as false, the video will be saved at app-specific file directory.
159+
### AppSpecificStorageConfiguration Configuration values
147160

148-
- saveAt: the directory where the video should be saved in. The value will be ignored if isExternal is false.
161+
- videoName: a custom name for the output video.
162+
163+
- saveAt: the directory where the video should be saved in. Must be one of the following; [SaveLocation.pictures], [SaveLocation.movies], or [SaveLocation.downloads].
149164

150165

151166
To cancel the compression job, just call [VideoCompressor.cancel()]
@@ -156,12 +171,17 @@ To cancel the compression job, just call [VideoCompressor.cancel()]
156171
VideoCompressor.start(
157172
context = applicationContext, // => This is required
158173
uris = List<Uri>, // => Source can be provided as content uris
159-
isStreamable = true,
160-
storageConfiguration = StorageConfiguration(
161-
saveAt = Environment.DIRECTORY_MOVIES, // => the directory to save the compressed video(s). Will be ignored if isExternal = false.
162-
isExternal = true, // => false means save at app-specific file directory. Default is true.
163-
fileName = "output-video.mp4" // => an optional value for a custom video name.
174+
isStreamable = false,
175+
// THIS STORAGE
176+
sharedStorageConfiguration = SharedStorageConfiguration(
177+
saveAt = SaveLocation.movies, // => default is movies
178+
videoName = "compressed_video" // => required name
164179
),
180+
// OR AND NOT BOTH
181+
appSpecificStorageConfiguration = AppSpecificStorageConfiguration(
182+
videoName = "compressed_video", // => required name
183+
subFolderName = "my-videos" // => optional and ONLY if exists
184+
),
165185
configureWith = Configuration(
166186
quality = VideoQuality.MEDIUM,
167187
isMinBitrateCheckEnabled = true,
@@ -197,59 +217,6 @@ VideoCompressor.start(
197217
}
198218
)
199219
```
200-
### Java
201-
202-
```java
203-
VideoCompressor.start(
204-
applicationContext, // => This is required
205-
new ArrayList<Uri>(), // => Source can be provided as content uris
206-
false, // => isStreamable
207-
new StorageConfiguration(
208-
"output-video.mp4" // => an optional value for a custom video name.
209-
Environment.DIRECTORY_DOWNLOADS, // => the directory to save the compressed video(s). Will be ignored if isExternal = false.
210-
true // => false means save at app-specific file directory. Default is true.
211-
),
212-
new Configuration(
213-
VideoQuality.MEDIUM,
214-
false, /*isMinBitrateCheckEnabled*/
215-
5, /*videoBitrateInMbps: int, or null*/
216-
false, /*disableAudio: Boolean, or null*/
217-
false, /*keepOriginalResolution: Boolean, or null*/
218-
360.0, /*videoWidth: Double, or null*/
219-
480.0 /*videoHeight: Double, or null*/
220-
),
221-
new CompressionListener() {
222-
@Override
223-
public void onStart(int index, long size) {
224-
// Compression start
225-
}
226-
227-
@Override
228-
public void onSuccess(int index, @Nullable String path) {
229-
// On Compression success
230-
}
231-
232-
@Override
233-
public void onFailure(int index, String failureMessage) {
234-
// On Failure
235-
}
236-
237-
@Override
238-
public void onProgress(int index, float progressPercent) {
239-
// Update UI with progress value
240-
runOnUiThread(new Runnable() {
241-
public void run() {
242-
}
243-
});
244-
}
245-
246-
@Override
247-
public void onCancelled(int index) {
248-
// On Cancelled
249-
}
250-
}
251-
);
252-
```
253220

254221
## Common issues
255222

@@ -263,7 +230,7 @@ from within the main thread. Have a look at the example code above for more info
263230
To report an issue, please specify the following:
264231
- Device name
265232
- Android version
266-
- If the bug/issue exists on the sample app (version 1.2.2) of the library that could be downloaded at this [link](https://drive.google.com/file/d/1GXblLAg1hnCa0Ef79iweQGvn1rLOYph8/view?usp=share_link).
233+
- If the bug/issue exists on the sample app (version 1.2.3) of the library that could be downloaded at this [link](https://drive.google.com/file/d/1WZtHN8gG2TaDuuTDKi9wB3B_sT_0SJ4w/view?usp=share_link).
267234

268235
## Compatibility
269236
Minimum Android SDK: LightCompressor requires a minimum API level of 21.
@@ -293,7 +260,7 @@ Include this in your Module-level build.gradle file:
293260
### Groovy
294261

295262
```groovy
296-
implementation 'com.github.AbedElazizShe:LightCompressor:1.2.2'
263+
implementation 'com.github.AbedElazizShe:LightCompressor:1.2.3'
297264
```
298265

299266
If you're facing problems with the setup, edit settings.gradle by adding this at the beginning of the file:

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ dependencies {
3232
implementation project(':lightcompressor')
3333

3434
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20"
35-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
36-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
35+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
36+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1"
3737

3838
implementation 'androidx.appcompat:appcompat:1.5.1'
3939
implementation 'androidx.core:core-ktx:1.9.0'

app/src/main/java/com/abedelazizshe/lightcompressor/MainActivity.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import android.content.pm.PackageManager
99
import android.net.Uri
1010
import android.os.Build
1111
import android.os.Bundle
12-
import android.os.Environment
1312
import android.provider.MediaStore
1413
import android.util.Log
1514
import android.view.View
@@ -22,7 +21,8 @@ import com.abedelazizshe.lightcompressorlibrary.CompressionListener
2221
import com.abedelazizshe.lightcompressorlibrary.VideoCompressor
2322
import com.abedelazizshe.lightcompressorlibrary.VideoQuality
2423
import com.abedelazizshe.lightcompressorlibrary.config.Configuration
25-
import com.abedelazizshe.lightcompressorlibrary.config.StorageConfiguration
24+
import com.abedelazizshe.lightcompressorlibrary.config.SaveLocation
25+
import com.abedelazizshe.lightcompressorlibrary.config.SharedStorageConfiguration
2626
import kotlinx.android.synthetic.main.activity_main.*
2727
import kotlinx.coroutines.GlobalScope
2828
import kotlinx.coroutines.launch
@@ -166,7 +166,6 @@ class MainActivity : AppCompatActivity() {
166166
}
167167
}
168168

169-
170169
@SuppressLint("SetTextI18n")
171170
private fun processVideo() {
172171
mainContents.visibility = View.VISIBLE
@@ -175,11 +174,14 @@ class MainActivity : AppCompatActivity() {
175174
VideoCompressor.start(
176175
context = applicationContext,
177176
uris,
178-
isStreamable = true,
179-
storageConfiguration = StorageConfiguration(
180-
saveAt = Environment.DIRECTORY_MOVIES,
181-
isExternal = true,
177+
isStreamable = false,
178+
sharedStorageConfiguration = SharedStorageConfiguration(
179+
saveAt = SaveLocation.movies,
180+
videoName = "compressed_video"
182181
),
182+
// appSpecificStorageConfiguration = AppSpecificStorageConfiguration(
183+
// videoName = "compressed_video",
184+
// ),
183185
configureWith = Configuration(
184186
quality = VideoQuality.LOW,
185187
isMinBitrateCheckEnabled = true,

lightcompressor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ afterEvaluate {
3838
from components.release
3939
groupId = "com.github.AbedElazizShe"
4040
artifactId = "LightCompressor"
41-
version = '1.2.2'
41+
version = '1.2.3'
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)