Downloader

Overview

The Downloader class is used internally and provided to users as a convenient mechanism for pre-caching audio located at a URL.
The Downloader class can actually be used to download any resource.
The Downloader class downloads the URL and saves it into a local file.
It is your responsibility to delete the local file once you have finished with it.
1
var saveToFile = TempMediaFile().empty();
2
​
3
await Downloader.download('https://some/path/rock.aac', saveToFile);
4
​
5
var track = Track.fromPath(saveToFile);
6
...
7
FileUtil().delete(saveToFile);
Copied!
You can also obtain download progress information.
1
var saveToFile = TempMediaFile().empty();
2
​
3
await Downloader.download('https://some/path/rock.aac', saveToFile, progress: (disposition) {
4
print('progress ${disposition.state}, ${disposition.progress}';
5
});
Copied!
Last modified 7mo ago
Copy link