1:优化礼物播放和下载方式

This commit is contained in:
2025-08-27 23:25:34 +08:00
parent 6a7be63284
commit 40a32a4218

View File

@@ -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