Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause/Resume download with HlsDownloader or DashDownloader #3907

Closed
pmunizferreira opened this issue Feb 27, 2018 · 6 comments
Closed

Pause/Resume download with HlsDownloader or DashDownloader #3907

pmunizferreira opened this issue Feb 27, 2018 · 6 comments
Assignees
Labels

Comments

@pmunizferreira
Copy link

Hi, I'm using exoplayer2.source.hls.offline.HlsDownloader and exoplayer2.source.dash.offline.DashDownloader to download videos that will be played offline later. I do not need an instance of Exoplayer at this time, just Downloader classes.
Are there ways to pause and resume the download?

A simple code to start download (working fine):

 val tempFolder = Util.createTempDirectory(context, "tempFolder");
 val cache = SimpleCache(tempFolder, NoOpCacheEvictor())
 val dataSourceFactory = CacheDataSourceFactory(context, 100 * 1024 * 1024, 5 * 1024 * 1024)

 val hlsDownloader = HlsDownloader(Uri.parse(videoUrl), DownloaderConstructorHelper(cache, dataSourceFactory))

 hlsDownloader.download(object: Downloader.ProgressListener {
    override fun onDownloadProgress(downloader: Downloader?, downloadPercentage: Float, downloadedBytes: Long) {
       ...
    }
  })

I've also tried the exoplayer2.upstream.CacheUtil class, but it also has no way to pause/resume downloads.
Maybe another class should be used to download videos? vov
thanks.

@pmunizferreira pmunizferreira changed the title Pause download with HlsDownloader or DashDownloader Pause/Resume download with HlsDownloader or DashDownloader Feb 27, 2018
@erdemguven
Copy link
Contributor

It's recommended to use recently released DownloadManager and DownloadService instead of Downloaders directly. DownloadManager has stopDownloads and startDownloads methods.

For Downloaders: You can interrupt the thread which the downloader or CacheUtil method is running:
thread.interrupt();
then the method will throw an InterruptedException. Next time you call the same method, it will continue from where it left.

@Waleedasim
Copy link

Waleedasim commented May 15, 2018

@pmunizferreira can you please tell me how you successfully download hls videos my mobile got hanged when onProgress called. here is my email address please contact
waleedasim08@gmail.com

@Waleedasim
Copy link

@erdemguven i am stuck at hls downloading your blog is not enough kindly tell me proper way for download video in mobile storage any working code example would be grate full but dont give me a link for demo app its too complicated

@erdemguven
Copy link
Contributor

@Waleedasim sorry there isn't a simple hls download example currently. I'll write another post for downloading adaptive streams soon.

@Waleedasim
Copy link

Waleedasim commented May 15, 2018 via email

@Waleedasim
Copy link

Waleedasim commented May 15, 2018 via email

@google google locked and limited conversation to collaborators Jun 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants