Merge pull request #3459 from dreampiggy/bugfix/player_cache_poster_image

The poster image should not trigger a frameChange callback
This commit is contained in:
DreamPiggy 2022-12-27 15:47:17 +08:00 committed by GitHub
commit 707db2e016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -145,18 +145,18 @@
if (!self.currentFrame && [self.animatedProvider isKindOfClass:[UIImage class]]) { if (!self.currentFrame && [self.animatedProvider isKindOfClass:[UIImage class]]) {
UIImage *image = (UIImage *)self.animatedProvider; UIImage *image = (UIImage *)self.animatedProvider;
// Use the poster image if available // Cache the poster image if available, but should not callback to avoid caller thread issues
#if SD_MAC #if SD_MAC
UIImage *posterFrame = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp]; UIImage *posterFrame = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp];
#else #else
UIImage *posterFrame = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation]; UIImage *posterFrame = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation];
#endif #endif
if (posterFrame) { if (posterFrame) {
self.currentFrame = posterFrame; // HACK: The first frame should not check duration and immediately display
self.needsDisplayWhenImageBecomesAvailable = YES;
SD_LOCK(self->_lock); SD_LOCK(self->_lock);
self.frameBuffer[@(self.currentFrameIndex)] = self.currentFrame; self.frameBuffer[@(self.currentFrameIndex)] = posterFrame;
SD_UNLOCK(self->_lock); SD_UNLOCK(self->_lock);
[self handleFrameChange];
} }
} }