From 8ebbb4a2d4778c39ee122f78d41e5791164ece18 Mon Sep 17 00:00:00 2001 From: hugh <1012760428@qq.com> Date: Sat, 31 Jan 2026 20:29:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=AE=8C=E6=88=90=E5=90=8E=E4=B8=8D=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=92=8C=E7=94=BB=E9=9D=A2=E6=AE=8B=E7=95=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 videoCompleted 标志,用于触发视频完成后的媒体切换 - 在 drawWallpaper() 中检查 videoCompleted 标志并切换到下一个媒体 - 在 stopVideo() 中调用 clearSurface() 清除视频最后画面 - 修复了视频播放完成后不自动切换的问题 - 修复了从视频切换到图片时画面残留的问题 Co-Authored-By: Claude Sonnet 4.5 --- .../bz/gk2/wallpaper/AutoWallpaperService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java index c4f11be..1c5255f 100644 --- a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java +++ b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java @@ -124,6 +124,7 @@ public class AutoWallpaperService extends WallpaperService { private volatile boolean isLoadingWallpaper = false; // 防止重复加载 private boolean isCharging = true; // Default to charging to avoid pausing initially private boolean changeOnReturn = false; // 标志:是否因返回桌面而需要更换壁纸 + private boolean videoCompleted = false; // 标志:视频播放完成,需要切换到下一个媒体 // 双击检测相关 private long lastTapTime = 0; @@ -201,7 +202,8 @@ public class AutoWallpaperService extends WallpaperService { return; } - // 重置状态标志(只有在确定要执行切换时才重置) + // 设置视频完成标志,触发切换到下一个媒体 + videoCompleted = true; isLoadingWallpaper = false; isPlayingVideo = false; @@ -211,8 +213,8 @@ public class AutoWallpaperService extends WallpaperService { drawWallpaper(); } catch (Exception e) { fileLogger.error(TAG, "Error switching to next media after video completion", e); + videoCompleted = false; isLoadingWallpaper = false; - isPlayingVideo = false; // 确保状态一致 } }); } @@ -362,7 +364,7 @@ public class AutoWallpaperService extends WallpaperService { boolean shouldChange = false; String statusMsg = "drawWallpaper: forceChangeNext=" + forceChangeNext + ", scheduledNext=" + scheduledNext + - ", changeOnReturn=" + changeOnReturn; + ", changeOnReturn=" + changeOnReturn + ", videoCompleted=" + videoCompleted; Log.i(TAG, statusMsg); fileLogger.log(TAG, statusMsg); @@ -375,6 +377,9 @@ public class AutoWallpaperService extends WallpaperService { } else if (changeOnReturn) { shouldChange = true; fileLogger.log(TAG, "Change on return to home"); + } else if (videoCompleted) { + shouldChange = true; + fileLogger.log(TAG, "Video playback completed, switching to next media"); } // 重置标志 @@ -382,6 +387,7 @@ public class AutoWallpaperService extends WallpaperService { forceChangeNext = false; scheduledNext = false; changeOnReturn = false; // 重置返回桌面标志 + videoCompleted = false; // 重置视频完成标志 // 如果不需要更换且有缓存,保持当前媒体 if (!needChange && currentMedia != null) { @@ -839,6 +845,8 @@ public class AutoWallpaperService extends WallpaperService { if (isPlayingVideo) { videoPlayer.release(); isPlayingVideo = false; + // 清除视频画面,避免保留最后帧 + clearSurface(); } }