Skip to content

Commit

Permalink
adding firstFrameImageForVideo feature
Browse files Browse the repository at this point in the history
  • Loading branch information
numen31337 committed Aug 13, 2021
1 parent 3bf3d5d commit d1db53b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AKVideoImageView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AKVideoImageView"
s.version = "1.1.3"
s.version = "1.1.4"
s.summary = "UIImageView subclass for displaying looped videos"
s.description = "UIImageView subclass that allows you to display a looped video and dynamically switch it"
s.homepage = "https://github.com/numen31337/AKVideoImageView"
Expand Down
3 changes: 3 additions & 0 deletions Classes/AKVideoImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
- (nullable instancetype)initWithFrame:(CGRect)frame
videoURL:(nonnull NSURL *)videoURL NS_DESIGNATED_INITIALIZER;

/** Returns the first frame of the video as a UIImage */
+ (nullable UIImage *)firstFrameImageForVideo:(nonnull NSURL *)videoURL;

@end
10 changes: 8 additions & 2 deletions Classes/AKVideoImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,17 @@ - (void)showFirstFrame
{
NSCParameterAssert([self.videoURL isKindOfClass:[NSURL class]]);

UIImage *firstFrameUIImage = [self thumbnailImageForVideo:self.videoURL atTime:0];
UIImage *firstFrameUIImage = [[self class] firstFrameImageForVideo:self.videoURL];
self.image = firstFrameUIImage;
}

- (nullable UIImage *)thumbnailImageForVideo:(nonnull NSURL *)videoURL
+ (nullable UIImage *)firstFrameImageForVideo:(nonnull NSURL *)videoURL {
NSCParameterAssert([videoURL isKindOfClass:[NSURL class]]);

return [[self class] thumbnailImageForVideo:videoURL atTime:0];
}

+ (nullable UIImage *)thumbnailImageForVideo:(nonnull NSURL *)videoURL
atTime:(NSTimeInterval)time
{
NSCParameterAssert([videoURL isKindOfClass:[NSURL class]]);
Expand Down

0 comments on commit d1db53b

Please sign in to comment.