From 40a32a4218663a7152d42a1e8ad11ea7a077a020 Mon Sep 17 00:00:00 2001 From: liangxiaojiang <461355754@qq.com> Date: Wed, 27 Aug 2025 23:25:34 +0800 Subject: [PATCH] =?UTF-8?q?1:=E4=BC=98=E5=8C=96=E7=A4=BC=E7=89=A9=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=92=8C=E4=B8=8B=E8=BD=BD=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xscm/moduleutil/widget/AvatarFrameView.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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