M3U8下载器,支持多线程下载、断点续传、后台下载、本地播放解决方案、m3u8加密解决方案
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.Jay-Goo:M3U8Downloader:V1.0.6'
}
- default Config:
M3U8DownloaderConfig
.build(getApplicationContext())
.setSaveDir(dirPath)
;
- Custom Config:
M3U8DownloaderConfig
.build(getApplicationContext())
.setSaveDir(dirPath)
.setConnTimeout(10000)
.setReadTimeout(10000)
.setThreadCount(3)
.setDebugMode(true)
;
M3U8Downloader.getInstance()
download(String url)
pause(String url)
cancel(String url)
cancelAndDelete(final String url, final OnDeleteTaskListener listener)
M3U8Downloader.getInstance().setOnM3U8DownloadListener(onM3U8DownloadListener);
private OnM3U8DownloadListener onM3U8DownloadListener = new OnM3U8DownloadListener() {
@Override
public void onDownloadItem(M3U8Task task, long itemFileSize, int totalTs, int curTs) {
super.onDownloadItem(task, itemFileSize, totalTs, curTs);
//下载切片监听,非UI线程
}
@Override
public void onDownloadSuccess(M3U8Task task) {
super.onDownloadSuccess(task);
//下载成功
}
@Override
public void onDownloadPending(M3U8Task task) {
super.onDownloadPending(task);
//加入队列,任务挂起
}
@Override
public void onDownloadPause(M3U8Task task) {
super.onDownloadPause(task);
//任务暂停
}
@Override
public void onDownloadProgress(final M3U8Task task) {
super.onDownloadProgress(task);
//下载进度,非UI线程
}
@Override
public void onDownloadPrepare(final M3U8Task task) {
super.onDownloadPrepare(task);
//准备下载
}
@Override
public void onDownloadError(final M3U8Task task, Throwable errorMsg) {
super.onDownloadError(task, errorMsg);
//下载错误,非UI线程
}
};
private String url; //下载链接
private int state = M3U8TaskState.DEFAULT; //下载状态
private long speed; //下载速度
private float progress; //下载进度
private M3U8 m3U8; //下载成功后得到
加密后视频切片文件名乱序,并移除后缀。
//设置密匙
M3U8Downloader.getInstance().setEncryptKey(encryptKey);
//获取随机密匙
AES128Utils.getAESKey()
更多加密解密 M3U8EncryptHelper
普通未加密请使用 M3U8HttpServer
加密请参考 EncryptM3U8Server
具体使用样例参考 FullScreenActivity