修复加密的m3u8下载,并且使用索引模式时,key的uri没有使用双引号的问题 https://github.com/AriaLyy/Aria/issues/731
修复删除m3u8索引文件后,下载完成回调无法触发的问题
This commit is contained in:
@@ -95,7 +95,7 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader<DTaskWrapper> {
|
||||
i++;
|
||||
} else if (line.startsWith("#EXT-X-KEY")) {
|
||||
M3U8Entity m3U8Entity = getEntity().getM3U8Entity();
|
||||
String keyInfo = String.format("#EXT-X-KEY:METHOD=%s,URI=%s,IV=%s\r\n", m3U8Entity.method,
|
||||
String keyInfo = String.format("#EXT-X-KEY:METHOD=%s,URI=\"%s\",IV=%s\r\n", m3U8Entity.method,
|
||||
m3U8Entity.keyPath, m3U8Entity.iv);
|
||||
bytes = keyInfo.getBytes(Charset.forName("UTF-8"));
|
||||
} else {
|
||||
|
||||
@@ -141,7 +141,7 @@ final public class M3U8InfoTask implements IInfoTask {
|
||||
}
|
||||
fos = new FileOutputStream(indexFile);
|
||||
ALog.d(TAG, line);
|
||||
addIndexInfo(isGenerateIndexFile, fos, line);
|
||||
addIndexInfo(true, fos, line);
|
||||
}
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (isStop) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.arialyy.aria.m3u8.vod;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import com.arialyy.aria.core.ThreadRecord;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
@@ -160,6 +161,11 @@ final class M3U8VodLoader extends BaseM3U8Loader {
|
||||
|
||||
// 启动定时器
|
||||
startTimer();
|
||||
if (getStateManager().isComplete()){
|
||||
Log.d(TAG, "任务已完成");
|
||||
getStateManager().handleTaskComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
// 启动线程开始下载ts切片
|
||||
Thread th = new Thread(new Runnable() {
|
||||
|
||||
@@ -139,28 +139,7 @@ public final class VodStateManager implements IThreadStateManager {
|
||||
loader.notifyWaitLock(true);
|
||||
}
|
||||
if (isComplete()) {
|
||||
ALog.d(TAG, String.format(
|
||||
"startThreadNum = %s, stopNum = %s, cancelNum = %s, failNum = %s, completeNum = %s, flagQueueSize = %s",
|
||||
startThreadNum, stopNum, cancelNum, failNum, loader.getCompleteNum(),
|
||||
loader.getCurrentFlagSize()));
|
||||
ALog.d(TAG, String.format("vod任务【%s】完成", loader.getTempFile().getName()));
|
||||
|
||||
if (m3U8Option.isGenerateIndexFile()) {
|
||||
if (loader.generateIndexFile(false)) {
|
||||
listener.onComplete();
|
||||
} else {
|
||||
listener.onFail(false, new AriaM3U8Exception("创建索引文件失败"));
|
||||
}
|
||||
} else if (m3U8Option.isMergeFile()) {
|
||||
if (mergeFile()) {
|
||||
listener.onComplete();
|
||||
} else {
|
||||
listener.onFail(false, null);
|
||||
}
|
||||
} else {
|
||||
listener.onComplete();
|
||||
}
|
||||
quitLooper();
|
||||
handleTaskComplete();
|
||||
}
|
||||
break;
|
||||
case STATE_RUNNING:
|
||||
@@ -175,6 +154,34 @@ public final class VodStateManager implements IThreadStateManager {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理m3u8以完成
|
||||
*/
|
||||
void handleTaskComplete() {
|
||||
ALog.d(TAG, String.format(
|
||||
"startThreadNum = %s, stopNum = %s, cancelNum = %s, failNum = %s, completeNum = %s, flagQueueSize = %s",
|
||||
startThreadNum, stopNum, cancelNum, failNum, loader.getCompleteNum(),
|
||||
loader.getCurrentFlagSize()));
|
||||
ALog.d(TAG, String.format("vod任务【%s】完成", loader.getTempFile().getName()));
|
||||
|
||||
if (m3U8Option.isGenerateIndexFile()) {
|
||||
if (loader.generateIndexFile(false)) {
|
||||
listener.onComplete();
|
||||
} else {
|
||||
listener.onFail(false, new AriaM3U8Exception("创建索引文件失败"));
|
||||
}
|
||||
} else if (m3U8Option.isMergeFile()) {
|
||||
if (mergeFile()) {
|
||||
listener.onComplete();
|
||||
} else {
|
||||
listener.onFail(false, null);
|
||||
}
|
||||
} else {
|
||||
listener.onComplete();
|
||||
}
|
||||
quitLooper();
|
||||
}
|
||||
|
||||
void updateStateCount() {
|
||||
cancelNum.set(0);
|
||||
stopNum.set(0);
|
||||
|
||||
Reference in New Issue
Block a user