diff --git a/DEV_LOG.md b/DEV_LOG.md index c51d13ab..036c9fc3 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,6 +1,7 @@ ## 开发日志 + v_3.8.15 - 修复不支持断点的连接下载失败问题,https://github.com/AriaLyy/Aria/issues/771 + - 修复iv不存在时,索引文件异常的问题,https://github.com/AriaLyy/Aria/issues/780 + v_3.8.14 (2020/9/23) - 修复spi机制的兼容问题,https://github.com/AriaLyy/Aria/issues/743 - 增加路径不可以写的判断,下载时,如果路径不可写,将执行失败回调 https://github.com/AriaLyy/Aria/issues/750 diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java index 3b06165a..10ee5523 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/BaseM3U8Loader.java @@ -95,9 +95,21 @@ public abstract class BaseM3U8Loader extends AbsNormalLoader { 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")); + StringBuilder sb = new StringBuilder("#EXT-X-KEY:"); + sb.append("METHOD=").append(m3U8Entity.method); + sb.append(",URI=\"").append(m3U8Entity.keyPath).append("\""); + if (!TextUtils.isEmpty(m3U8Entity.iv)) { + sb.append(",IV=").append(m3U8Entity.iv); + } + if (!TextUtils.isEmpty(m3U8Entity.keyFormat)) { + sb.append(",KEYFORMAT=\"").append(m3U8Entity.keyFormat).append("\""); + sb.append(",KEYFORMATVERSIONS=\"") + .append(TextUtils.isEmpty(m3U8Entity.keyFormatVersion) ? "1" + : m3U8Entity.keyFormatVersion) + .append("\""); + } + sb.append("\r\n"); + bytes = sb.toString().getBytes(Charset.forName("UTF-8")); } else { bytes = line.concat("\r\n").getBytes(Charset.forName("UTF-8")); }