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 4d322a2..970a77e 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 @@ -186,16 +186,19 @@ public class AutoWallpaperService extends WallpaperService { public void onCompletion() { fileLogger.log(TAG, "Video completed, switching to next media"); - // 重置状态标志 - isLoadingWallpaper = false; - isPlayingVideo = false; - // 检查 Surface 是否仍然有效 if (!visible) { fileLogger.log(TAG, "Surface not visible, skipping auto-switch"); + // 在这里重置状态,因为确实不需要加载了 + isLoadingWallpaper = false; + isPlayingVideo = false; return; } + // 重置状态标志(只有在确定要执行切换时才重置) + isLoadingWallpaper = false; + isPlayingVideo = false; + // 触发切换到下一个媒体 handler.post(() -> { try { @@ -203,6 +206,7 @@ public class AutoWallpaperService extends WallpaperService { } catch (Exception e) { fileLogger.error(TAG, "Error switching to next media after video completion", e); isLoadingWallpaper = false; + isPlayingVideo = false; // 确保状态一致 } }); }