youtubedl-android
youtubedl-android copied to clipboard
Background task inquiry
There is a conversion process when downloading MP3s. In the case of a video over an hour, the conversion takes too long. And when I move the app to home, it doesn't seem to work in the background. Is it possible to check?
Maybe we should use WorkManager.
Edit: Checkout dvd, a video downloader app based on this library it is using WorkManager.
Maybe we should use WorkManager.
Edit: Checkout dvd, a video downloader app based on this library it is using WorkManager.
Is it possible to convert even in the background to a work manager or foreground service?
yes, with workmanager you can download a video and convert it to mp3 even if the video is more than 3 hours the download will continue in the background.
yes, with workmanager you can download a video and convert it to mp3 even if the video is more than 3 hours the download will continue in the background.
I called work manager as below I added the request option in doWork and executed it. Is it correct to do this?
OneTimeWorkRequest mathWork = new OneTimeWorkRequest.Builder(DownloadWorker.class).build(); WorkManager.getInstance(context).enqueue(mathWork);
For example
Constraints.Builder builder = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED);
// Passing params
Data.Builder data = new Data.Builder();
data.putString("tag", tag);
data.putString("url", url);
data.putString("title", title);
data.putString("format", format);
OneTimeWorkRequest syncWorkRequest = new OneTimeWorkRequest.Builder(DownloadWorker.class)
.addTag(tag)
.setInputData(data.build())
.setConstraints(builder.build())
.build();
WorkManager.getInstance(context).enqueueUniqueWork(tag, ExistingWorkPolicy.KEEP, syncWorkRequest);
Also for more information please see this https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running