m3u8增加了ignoreFailureTs方法,忽略虾类失败的ts切片
修复在dialogFragment的`onCreateDialog()`注册导致的注解不生效问题
This commit is contained in:
@@ -255,6 +255,10 @@ final public class M3U8InfoThread implements Runnable {
|
||||
m3U8Entity.keyUrl) + ".key";
|
||||
} else if (param.startsWith("IV")) {
|
||||
m3U8Entity.iv = param.split("=")[1];
|
||||
}else if (param.startsWith("KEYFORMAT")){
|
||||
m3U8Entity.keyFormat = param.split("=")[1];
|
||||
}else if (param.startsWith("KEYFORMATVERSIONS")){
|
||||
m3U8Entity.keyFormatVersion = param.split("=")[1];
|
||||
}
|
||||
}
|
||||
downloadKey(m3U8Entity);
|
||||
|
||||
@@ -109,6 +109,20 @@ public class M3U8TaskOption implements ITaskOption {
|
||||
*/
|
||||
private SoftReference<IKeyUrlConverter> keyUrlConverter;
|
||||
|
||||
/**
|
||||
* 忽略下载失败的ts切片。
|
||||
* true:即使有失败的切片,下载完成后也要合并所有切片,并进入complete回调
|
||||
*/
|
||||
private boolean ignoreFailureTs = false;
|
||||
|
||||
public boolean isIgnoreFailureTs() {
|
||||
return ignoreFailureTs;
|
||||
}
|
||||
|
||||
public void setIgnoreFailureTs(boolean ignoreFailureTs) {
|
||||
this.ignoreFailureTs = ignoreFailureTs;
|
||||
}
|
||||
|
||||
public IKeyUrlConverter getKeyUrlConverter() {
|
||||
return keyUrlConverter == null ? null : keyUrlConverter.get();
|
||||
}
|
||||
|
||||
@@ -221,9 +221,9 @@ public class M3U8VodLoader extends BaseM3U8Loader {
|
||||
}
|
||||
}
|
||||
mManager.updateStateCount();
|
||||
if (mCompleteNum <= 0){
|
||||
if (mCompleteNum <= 0) {
|
||||
mListener.onStart(0);
|
||||
}else {
|
||||
} else {
|
||||
int percent = mCompleteNum * 100 / mRecord.threadRecords.size();
|
||||
mListener.onResume(percent);
|
||||
}
|
||||
@@ -570,9 +570,9 @@ public class M3U8VodLoader extends BaseM3U8Loader {
|
||||
ALog.d(TAG, String.format("vod任务【%s】完成", mTempFile.getName()));
|
||||
|
||||
if (mM3U8Option.isGenerateIndexFile()) {
|
||||
if (generateIndexFile(false)){
|
||||
if (generateIndexFile(false)) {
|
||||
listener.onComplete();
|
||||
}else {
|
||||
} else {
|
||||
listener.onFail(false, new TaskException(TAG, "创建索引文件失败"));
|
||||
}
|
||||
} else if (mM3U8Option.isMergeFile()) {
|
||||
@@ -621,7 +621,11 @@ public class M3U8VodLoader extends BaseM3U8Loader {
|
||||
}
|
||||
|
||||
@Override public boolean isComplete() {
|
||||
return mCompleteNum == taskRecord.threadRecords.size() && !isJump;
|
||||
if (mM3U8Option.isIgnoreFailureTs()) {
|
||||
return mCompleteNum + failNum >= taskRecord.threadRecords.size() && !isJump;
|
||||
} else {
|
||||
return mCompleteNum == taskRecord.threadRecords.size() && !isJump;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public long getCurrentProgress() {
|
||||
|
||||
Reference in New Issue
Block a user