I've a Worker in which i first want to apply FFMPEG command before uploading it to server. As Worker is already running in background so to keep the result on hold until file uploads I've used RxJava .blockingGet() method. But I'm unable to understand that how to execute FFmpeg command synchronously by anyway i.e. RxJava etc. One tip that I found is to use ListenableWorker but it's documentation says that it stops working after 10 minutes. So, i don't want to go with that solution. Following is the method of FFmpeg just like any other async method. How can i make it synchronous or integrate it with RxJava? Any ideas would be appreciable.
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
}
@Override
public void onSuccess(String s) {
uploadMediaItem(mediaUpload);
}
@Override
public void onProgress(String s) {
}
@Override
public void onStart() {
}
@Override
public void onFinish() {
// countDownLatch.countDown();
}
});
This is the flow of my Worker:
- check pending post count in DB.
- Pick first post and check if it has pending media list to upload.
- Pick media recursively and check if editing is required on it or not.
- Apply FFmpeg editing and upload and delete from DB.
- Repeat the cycle until last entry in the DB.
Thanks