Exoplayer: Handle percent downloaded

Created on 16 Dec 2019  路  3Comments  路  Source: google/ExoPlayer

[REQUIRED] Searched documentation and issues

I've refered to document at https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/SimpleExoPlayer.Builder.html

[REQUIRED] Question

Hi guys! I want checking percent of video which downloading
I've used DownloadManger Listener to handle that

private class DownloadManagerListener implements DownloadManager.Listener {

        @Override
        public void onDownloadChanged(DownloadManager downloadManager, Download download) {
            downloads.put(download.request.uri, download);
            for (Listener listener : listeners) {
                listener.onDownloadsChanged(download.getPercentDownloaded());
            }
        }

        @Override
        public void onDownloadRemoved(DownloadManager downloadManager, Download download) {
            downloads.remove(download.request.uri);
            for (Listener listener : listeners) {
                listener.onDownloadsChanged(download.getPercentDownloaded());
            }
        }
    }

But download.getPercentDownloaded always is 0% on start download and 100% when download.
I want listener can be handle each percent of video download.
Hope reply and thanks everyone

question

All 3 comments

Hi,

My understanding is that this is WAI (Working As Intended). onDownloadChanged and onDownloadRemoved are only called when there is a change of state for the download. This means they are not called as the download is in progress, so the listener does not get called every time 1% more is downloaded.

Please look at listening to downloads on our website.

Thanks.

@Samrobbo Thank you. I did it :D

Brilliant to hear! If you run into future problems, feel free to file a new issue, we're always happy to help.

Was this page helpful?
0 / 5 - 0 ratings