|
|
|
@ -16,6 +16,7 @@ |
|
|
|
|
package com.arialyy.aria.m3u8; |
|
|
|
|
|
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DTaskWrapper; |
|
|
|
|
import com.arialyy.aria.core.download.DownloadEntity; |
|
|
|
|
import com.arialyy.aria.core.download.M3U8Entity; |
|
|
|
@ -23,6 +24,7 @@ import com.arialyy.aria.core.listener.IEventListener; |
|
|
|
|
import com.arialyy.aria.core.loader.AbsNormalLoader; |
|
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
|
import com.arialyy.aria.util.FileUtil; |
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
@ -41,7 +43,8 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader<DTaskWrapper> { |
|
|
|
|
mTempFile = new File(wrapper.getEntity().getFilePath()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override protected long delayTimer() { |
|
|
|
|
@Override |
|
|
|
|
protected long delayTimer() { |
|
|
|
|
return 1000; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -95,9 +98,19 @@ 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, |
|
|
|
|
m3U8Entity.keyPath, m3U8Entity.iv); |
|
|
|
|
bytes = keyInfo.getBytes(Charset.forName("UTF-8")); |
|
|
|
|
StringBuffer stringBuffer = new StringBuffer("#EXT-X-KEY:"); |
|
|
|
|
//这里还原原M3U8文件的加密方式,URI,IV等
|
|
|
|
|
if (!TextUtils.isEmpty(m3U8Entity.method)) { |
|
|
|
|
//加密方式
|
|
|
|
|
stringBuffer.append("METHOD=").append(m3U8Entity.method); |
|
|
|
|
} else if (!TextUtils.isEmpty(m3U8Entity.keyPath)) { |
|
|
|
|
//key地址
|
|
|
|
|
stringBuffer.append(",URI=").append(m3U8Entity.keyPath); |
|
|
|
|
} else if (TextUtils.isEmpty(m3U8Entity.iv)) { |
|
|
|
|
//向量
|
|
|
|
|
stringBuffer.append(",IV=").append(m3U8Entity.iv).append("\r\n"); |
|
|
|
|
} |
|
|
|
|
bytes = stringBuffer.toString().getBytes(Charset.forName("UTF-8")); |
|
|
|
|
} else { |
|
|
|
|
bytes = line.concat("\r\n").getBytes(Charset.forName("UTF-8")); |
|
|
|
|
} |
|
|
|
@ -133,7 +146,8 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader<DTaskWrapper> { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override public long getCurrentProgress() { |
|
|
|
|
@Override |
|
|
|
|
public long getCurrentProgress() { |
|
|
|
|
return isRunning() ? getStateManager().getCurrentProgress() : getEntity().getCurrentProgress(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|