Protect when animatedImage does not have CGImage (not possible in real situation)

This commit is contained in:
DreamPiggy 2021-02-22 19:45:16 +08:00
parent 8b1dfc01cf
commit ad067f7b4e
1 changed files with 6 additions and 2 deletions

View File

@ -78,8 +78,12 @@ public final class ImagePlayer : ObservableObject {
self.player = imagePlayer
let posterFrame = PlatformImage(cgImage: animatedImage.cgImage!, scale: animatedImage.scale, orientation: .up)
currentFrame = posterFrame
// Setup poster frame
if let cgImage = animatedImage.cgImage {
currentFrame = PlatformImage(cgImage: cgImage, scale: animatedImage.scale, orientation: .up)
} else {
currentFrame = .empty
}
}
}
}