diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java index 786b25a..7781ec9 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java @@ -361,18 +361,21 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener { String filePath = PathUtils.getInternalAppCachePath() + Md5Utils.getStringMD5(url) + ".mp4"; File file = new File(filePath); - if (file.exists()) { + if (file.exists() && file.length() > 0) { playMp4(file); mFile = file; } else { + // 删除可能存在的损坏文件 + if (file.exists()) { + file.delete(); + } DownloadTask task = new DownloadTask.Builder(url, PathUtils.getInternalAppCachePath() , Md5Utils.getStringMD5(url) + ".mp4") - .setMinIntervalMillisCallbackProcess(1000) + .setMinIntervalMillisCallbackProcess(300) .setPassIfAlreadyCompleted(true) .setAutoCallbackToUIThread(true) - - // 添加以下优化配置 - .setConnectionCount(1) // 对于大文件,减少连接数可能更稳定 + .setConnectionCount(3) // 增加连接数提高稳定性 + .setReadBufferSize(1024 * 8) // 增大缓冲区 .build(); if (StatusUtil.isCompleted(task)) { playMp4(task.getFile()); @@ -391,9 +394,7 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener { @Override public void retry(@NonNull DownloadTask task, @NonNull ResumeFailedCause cause) { Logger.e("AvatarFrameView2", cause); - task.cancel(); -// CrashReport.postCatchedException(new RuntimeException("下载文件重试:" + cause == null ? "" : cause.name())); } @Override