diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/HttpTaskOption.java b/HttpComponent/src/main/java/com/arialyy/aria/http/HttpTaskOption.java index d013f42e..fb898c70 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/HttpTaskOption.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/HttpTaskOption.java @@ -16,9 +16,10 @@ package com.arialyy.aria.http; +import android.text.TextUtils; import com.arialyy.aria.core.common.RequestEnum; -import com.arialyy.aria.core.processor.IHttpFileLenAdapter; import com.arialyy.aria.core.inf.ITaskOption; +import com.arialyy.aria.core.processor.IHttpFileLenAdapter; import java.lang.ref.SoftReference; import java.net.CookieManager; import java.net.Proxy; @@ -140,7 +141,7 @@ public class HttpTaskOption implements ITaskOption { } public String getCharSet() { - return charSet; + return TextUtils.isEmpty(charSet) ? "utf-8" : charSet; } public void setCharSet(String charSet) { diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java index ba680258..591cbf87 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8TaskOption.java @@ -120,7 +120,7 @@ public class M3U8TaskOption implements ITaskOption { } public int getMaxTsQueueNum() { - return maxTsQueueNum; + return maxTsQueueNum == 0 ? 4 : maxTsQueueNum; } public void setMaxTsQueueNum(int maxTsQueueNum) { @@ -128,7 +128,7 @@ public class M3U8TaskOption implements ITaskOption { } public long getLiveUpdateInterval() { - return liveUpdateInterval; + return liveUpdateInterval == 0 ? 10 * 1000 : liveUpdateInterval; } public void setLiveUpdateInterval(long liveUpdateInterval) { diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java index dc688518..5038c097 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java @@ -334,7 +334,7 @@ public class M3U8VodLoader extends BaseM3U8Loader { } /** - * 重指定位置恢复任务 + * 从指定位置恢复任务 */ private synchronized void resumeTask() { if (isBreak()) { diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodUtil.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodUtil.java index 1a7a1ebe..46f82d51 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodUtil.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodUtil.java @@ -82,7 +82,7 @@ public class M3U8VodUtil extends AbsNormalLoaderUtil { fail(new M3U8Exception(TAG, "获取地址失败"), false); return; } else if (!mUrls.get(0).startsWith("http")) { - fail(new M3U8Exception(TAG, "地址错误,请使用IM3U8UrlExtInfHandler处理你的url信息"), false); + fail(new M3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false); return; } mM3U8Option.setUrls(mUrls); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/TaskOptionParams.java b/PublicComponent/src/main/java/com/arialyy/aria/core/TaskOptionParams.java index 66512522..4d3a0f59 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/TaskOptionParams.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/TaskOptionParams.java @@ -18,10 +18,19 @@ package com.arialyy.aria.core; import com.arialyy.aria.core.common.BaseOption; import com.arialyy.aria.core.inf.IEventHandler; import com.arialyy.aria.core.inf.IOptionConstant; +import com.arialyy.aria.core.processor.FtpInterceptHandler; +import com.arialyy.aria.core.processor.IBandWidthUrlConverter; +import com.arialyy.aria.core.processor.IFtpUploadInterceptor; +import com.arialyy.aria.core.processor.IHttpFileLenAdapter; +import com.arialyy.aria.core.processor.ILiveTsUrlConverter; +import com.arialyy.aria.core.processor.ITsMergeHandler; +import com.arialyy.aria.core.processor.IVodTsUrlConverter; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -32,6 +41,8 @@ import java.util.Map; */ public class TaskOptionParams { + private static List PROCESSORES = new ArrayList<>(); + /** * 普通参数 */ @@ -42,18 +53,29 @@ public class TaskOptionParams { */ private Map handler = new HashMap<>(); + static { + PROCESSORES.add(FtpInterceptHandler.class); + PROCESSORES.add(IBandWidthUrlConverter.class); + PROCESSORES.add(IFtpUploadInterceptor.class); + PROCESSORES.add(IHttpFileLenAdapter.class); + PROCESSORES.add(ILiveTsUrlConverter.class); + PROCESSORES.add(ITsMergeHandler.class); + PROCESSORES.add(IVodTsUrlConverter.class); + } + /** * 设置任务参数 * * @param option 任务配置 */ public void setParams(BaseOption option) { - Field[] fields = CommonUtil.getFields(option.getClass()); + List fields = CommonUtil.getAllFields(option.getClass()); for (Field field : fields) { field.setAccessible(true); try { - if (field.getType() == IEventHandler.class) { + + if (PROCESSORES.contains(field.getType())) { Object eventHandler = field.get(option); if (eventHandler != null) { setObjs(field.getName(), (IEventHandler) eventHandler); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/ComponentUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/util/ComponentUtil.java index 600e6ae1..5ea85006 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/util/ComponentUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/util/ComponentUtil.java @@ -28,6 +28,7 @@ import java.lang.ref.SoftReference; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; +import java.util.List; /** * 组件工具,用于跨组件创建对应的工具类 @@ -210,7 +211,7 @@ public class ComponentUtil { * @return 构建失败,返回null */ public T buildTaskOption(Class clazz, TaskOptionParams params) { - Field[] fields = CommonUtil.getFields(clazz); + List fields = CommonUtil.getAllFields(clazz); T taskOption = null; try { taskOption = clazz.newInstance(); diff --git a/README.md b/README.md index c74f2625..1bc30f4c 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,16 @@ Aria有以下特点: ## 引入库 [![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/AriaLyy/Aria/blob/master/LICENSE) -[![Core](https://img.shields.io/badge/Core-3.7.1-blue)](https://github.com/AriaLyy/Aria) -[![Compiler](https://img.shields.io/badge/Compiler-3.7.1-blue)](https://github.com/AriaLyy/Aria) -[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.1-orange)](https://github.com/AriaLyy/Aria) -[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.1-orange)](https://github.com/AriaLyy/Aria) +[![Core](https://img.shields.io/badge/Core-3.7.2-blue)](https://github.com/AriaLyy/Aria) +[![Compiler](https://img.shields.io/badge/Compiler-3.7.2-blue)](https://github.com/AriaLyy/Aria) +[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.2-orange)](https://github.com/AriaLyy/Aria) +[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.2-orange)](https://github.com/AriaLyy/Aria) ```java -implementation 'com.arialyy.aria:core:3.7.1' -annotationProcessor 'com.arialyy.aria:compiler:3.7.1' -implementation 'com.arialyy.aria:ftpComponent:3.7.1' # 如果需要使用ftp,请增加该组件 -implementation 'com.arialyy.aria:m3u8Component:3.7.1' # 如果需要使用m3u8下载功能,请增加该组件 +implementation 'com.arialyy.aria:core:3.7.2' +annotationProcessor 'com.arialyy.aria:compiler:3.7.2' +implementation 'com.arialyy.aria:ftpComponent:3.7.2' # 如果需要使用ftp,请增加该组件 +implementation 'com.arialyy.aria:m3u8Component:3.7.2' # 如果需要使用m3u8下载功能,请增加该组件 ``` 如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:aria-core:'`替换为 ``` diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java index dd44584f..f04b6041 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java @@ -310,8 +310,6 @@ public class M3U8VodDLoadActivity extends BaseActivity { return option; } - private Class c = BuilderController.class; - @Override protected void dataCallback(int result, Object data) { super.dataCallback(result, data); if (result == ModifyUrlDialog.MODIFY_URL_DIALOG_RESULT) { diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/VideoPlayerFragment.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/VideoPlayerFragment.java index 501da945..0d281500 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/VideoPlayerFragment.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/VideoPlayerFragment.java @@ -1,6 +1,8 @@ package com.arialyy.simple.core.download.m3u8; import android.annotation.SuppressLint; +import android.graphics.Canvas; +import android.graphics.Color; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Build; @@ -37,6 +39,7 @@ public class VideoPlayerFragment extends BaseFragment