fix: 增强视频完成回调的错误处理
- 添加 Surface 可见性检查 - 添加异常捕获和日志记录 - 确保状态标志正确重置 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3d1916de62
commit
c0cb8e43d2
1 file changed
+17
-4
@@ -185,12 +185,25 @@ public class AutoWallpaperService extends WallpaperService {
|
||||
@Override
|
||||
public void onCompletion() {
|
||||
fileLogger.log(TAG, "Video completed, switching to next media");
|
||||
isLoadingWallpaper = false; // 允许新的加载请求
|
||||
isPlayingVideo = false; // 标记当前不在播放视频
|
||||
|
||||
// 触发切换到下一个媒体(不设置 forceChangeNext,使用正常流程)
|
||||
// 重置状态标志
|
||||
isLoadingWallpaper = false;
|
||||
isPlayingVideo = false;
|
||||
|
||||
// 检查 Surface 是否仍然有效
|
||||
if (!visible) {
|
||||
fileLogger.log(TAG, "Surface not visible, skipping auto-switch");
|
||||
return;
|
||||
}
|
||||
|
||||
// 触发切换到下一个媒体
|
||||
handler.post(() -> {
|
||||
drawWallpaper();
|
||||
try {
|
||||
drawWallpaper();
|
||||
} catch (Exception e) {
|
||||
fileLogger.error(TAG, "Error switching to next media after video completion", e);
|
||||
isLoadingWallpaper = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user