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(); } }