Closed prashantd123 closed 4 years ago
Thanks for opening this issue, have you added WRITE_EXTERNAL_STORAGE
permission ?
Could you please post the code where you pick the video and start the compression?
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data);
if (requestCode==GalleryPick && resultCode==RESULT_OK && data!=null)
{
Uri resultUri = data.getData(); // may be the problem here...
Videocompress(resultUri );
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void Videocompreg(String resultUri) {
File downloadsPath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File desFile = new File(downloadsPath, "${System.currentTimeMillis()}_${file.name}");
if (desFile.exists()) {
desFile.delete();
try {
desFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
VideoCompressor.INSTANCE.start(resultUri, desFile.getPath(), new CompressionListener() {
@Override
public void onStart() {
// Compression start
Toast.makeText(Main2Activity.this,"start",Toast.LENGTH_SHORT).show();
}
@Override
public void onSuccess() {
// On Compression success
Toast.makeText(Main2Activity.this,"success",Toast.LENGTH_SHORT).show();
String nst = desFile.getPath();
videoView.setVideoURI(Uri.parse(nst));
videoView.start();
}
@Override
public void onFailure(String failureMessage) {
// On Failure
Toast.makeText(Main2Activity.this,"Failure\n"+failureMessage,Toast.LENGTH_SHORT).show();
}
@Override
public void onProgress(float v) {
// Update UI with progress value
runOnUiThread(new Runnable() {
public void run() {
// progress.setText(progressPercent + "%");
// progressBar.setProgress((int) progressPercent);
}
});
}
@Override
public void onCancelled() {
// On Cancelled
Toast.makeText(Main2Activity.this,"Cancelled",Toast.LENGTH_SHORT).show();
}
}, VideoQuality.MEDIUM, false, false);
}
Thanks for opening this issue, have you added
WRITE_EXTERNAL_STORAGE
permission ?
Yes,
< uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> < uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Thank you for the details. Are you using ACTION_PICK or ACTION_GET_CONTENT when picking up the video ? Just ensure it is ACTION_PICK, there might be issues with video metadata if ACTION_GET_CONTENT was used.
Could you please try the sample app of the library and let me know if it is working? You can also share one of the videos that fail to my email and I will look into it to solve any potential issues.
I using Utils.kt from your sample app of the library and now its working smoothly.
String path = UtilsKt.getMediaPath(MainActivity.this , resultUri);
Thank you so much for your library, I searched everywhere and tried many libraries and codes from a week but finally your library is working... 😊👌
I am glad it's working and I appriciate your feed :D
Happy coding
Please help me...