├── .swift-version ├── LICENSE ├── PPVideoImage.podspec ├── PPVideoImage ├── PPCacheUtil.h ├── PPCacheUtil.m ├── PPVideoImageManager.h ├── PPVideoImageManager.m ├── UIImageView+VideoCache.h └── UIImageView+VideoCache.m ├── PPVideoImageDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── junghsu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── xuzhongping.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── junghsu.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── PPVideoImageDemo.xcscheme │ │ └── xcschememanagement.plist │ └── xuzhongping.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── PPVideoImageDemo.xcscheme │ └── xcschememanagement.plist ├── PPVideoImageDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── no_picture.imageset │ │ ├── Contents.json │ │ ├── no_picture@2x.png │ │ └── no_picture@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── PPTableViewCell.h ├── PPTableViewCell.m ├── PPTableViewCell.xib ├── ViewController.h ├── ViewController.m └── main.m ├── PPVideoImageDemoTests ├── Info.plist └── PPVideoImageDemoTests.m ├── PPVideoImageDemoUITests ├── Info.plist └── PPVideoImageDemoUITests.m ├── README.md └── videodemo.gif /.swift-version: -------------------------------------------------------------------------------- 1 | 2.3 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 徐仲平 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PPVideoImage.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | 4 | s.name = "PPVideoImage" 5 | s.version = "0.1.1" 6 | s.summary = "this is PPVideoImage" 7 | 8 | s.platform = :ios, '6.0' 9 | s.ios.deployment_target = '6.0' 10 | 11 | s.description = "PPVideoImage 快速设置视频的预览图" 12 | 13 | s.homepage = "https://github.com/JungHsu/PPVideoImage" 14 | 15 | s.license = { :type => 'MIT', :file => 'LICENSE' } 16 | 17 | s.author = { "JungHsu" => "1021057927@qq.com" } 18 | 19 | s.source = { :git => "https://github.com/JungHsu/PPVideoImage.git", :tag => "#{s.version}" } 20 | s.source_files = "PPVideoImage/**/*.{h,m}" 21 | s.requires_arc = true 22 | 23 | end 24 | -------------------------------------------------------------------------------- /PPVideoImage/PPCacheUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // PPCacheUtil.h 3 | // 4 | // 5 | // Created by xuzhongping on 2016/12/13. 6 | // Copyright © 2016年 JungHsu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PPCacheUtil : NSObject 12 | #define PPIMAGECACHE [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"PPImageCache"] 13 | 14 | + (instancetype)sharedCacheUtil; 15 | 16 | 17 | @property (nonatomic,strong)NSMutableDictionary *memoryCache; 18 | 19 | @property (nonatomic,strong)NSMutableDictionary *operations; 20 | 21 | @property (nonatomic,strong)NSMutableDictionary *placeholders; 22 | 23 | - (UIImage *)readDiskImage:(NSURL *)url; 24 | /** write to disk */ 25 | - (void)writeDiskCache:(UIImage *)diskImage url:(NSURL *)url; 26 | 27 | /** 删除磁盘的图片缓存 */ 28 | - (void)cleanDiskCacheCompleted:(void(^)(NSError *)) complete; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PPVideoImage/PPCacheUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // PPCacheUtil.m 3 | // 4 | // 5 | // Created by xuzhongping on 2016/12/13. 6 | // Copyright © 2016年 JungHsu. All rights reserved. 7 | // 8 | 9 | #import "PPCacheUtil.h" 10 | #import 11 | 12 | @implementation PPCacheUtil 13 | 14 | #pragma mark - 单例 15 | static id _instance; 16 | + (id)allocWithZone:(struct _NSZone *)zone 17 | { 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | _instance = [super allocWithZone:zone]; 21 | }); 22 | return _instance; 23 | } 24 | 25 | + (instancetype)sharedCacheUtil 26 | { 27 | static dispatch_once_t onceToken; 28 | dispatch_once(&onceToken, ^{ 29 | _instance = [[self alloc] init]; 30 | }); 31 | return _instance; 32 | } 33 | 34 | - (id)copyWithZone:(NSZone *)zone 35 | { 36 | return _instance; 37 | } 38 | 39 | - (instancetype)init{ 40 | if (self = [super init]) { 41 | __weak typeof(self) weakSelf = self; 42 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[[NSOperationQueue alloc]init] usingBlock:^(NSNotification * _Nonnull note) { 43 | [weakSelf cleanDiskCacheCompleted:nil]; 44 | }]; 45 | } 46 | return self; 47 | } 48 | 49 | 50 | #pragma mark - lazy 51 | 52 | - (NSMutableDictionary *)memoryCache{ 53 | if (!_memoryCache) { 54 | _memoryCache = @{}.mutableCopy; 55 | } 56 | return _memoryCache; 57 | } 58 | 59 | 60 | - (NSMutableDictionary *)operations{ 61 | if (!_operations) { 62 | _operations = @{}.mutableCopy; 63 | } 64 | return _operations; 65 | } 66 | 67 | - (NSMutableDictionary *)placeholders{ 68 | if (!_placeholders) { 69 | _placeholders = @{}.mutableCopy; 70 | } 71 | return _placeholders; 72 | } 73 | 74 | - (void)writeDiskCache:(UIImage *)diskImage url:(NSURL *)url{ 75 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 76 | if (![[NSFileManager defaultManager] fileExistsAtPath:PPIMAGECACHE]) { 77 | [[NSFileManager defaultManager] createDirectoryAtPath:PPIMAGECACHE withIntermediateDirectories:YES attributes:nil error:nil]; 78 | } 79 | NSString *path; 80 | NSRange range = [url.path rangeOfString:@"."]; 81 | path = [[self md5:[url.path substringToIndex:range.location]] stringByAppendingString:@".png"]; 82 | path = [PPIMAGECACHE stringByAppendingPathComponent:path]; 83 | NSData *resultData = [self zipImage:diskImage]; 84 | [resultData writeToFile:path atomically:YES]; 85 | }); 86 | } 87 | - (UIImage *)readDiskImage:(NSURL *)url{ 88 | NSString *path; 89 | NSRange range = [url.path rangeOfString:@"."]; 90 | path = [[self md5:[url.path substringToIndex:range.location]] stringByAppendingString:@".png"]; 91 | path = [PPIMAGECACHE stringByAppendingPathComponent:path]; 92 | return [UIImage imageWithContentsOfFile:path]; 93 | } 94 | 95 | 96 | - (NSString *) md5:(NSString *) input { 97 | const char *cStr = [input UTF8String]; 98 | unsigned char digest[CC_MD5_DIGEST_LENGTH]; 99 | CC_MD5( cStr, (CC_LONG)strlen(cStr), digest ); 100 | 101 | NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; 102 | for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) 103 | [output appendFormat:@"%02x", digest[i]]; 104 | return output; 105 | } 106 | 107 | - (void)cleanDiskCacheCompleted:(void (^)(NSError *error))complete{ 108 | __block NSError *error; 109 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 110 | [[NSFileManager defaultManager] removeItemAtPath:PPIMAGECACHE error:&error]; 111 | complete(error); 112 | }); 113 | } 114 | 115 | #pragma mark - private 116 | 117 | - (NSData *)zipImage:(UIImage *)image{ 118 | CGSize originalSize = image.size; 119 | NSData *data = nil; 120 | if (originalSize.width >= 500.0) { 121 | data = UIImageJPEGRepresentation(image, 0.2); 122 | }else 123 | if ( 500.0 > originalSize.width && originalSize.width >= 300.0){ 124 | data = UIImageJPEGRepresentation(image, 0.3); 125 | }else 126 | if (300.0 > originalSize.width && originalSize.width >= 100.0) { 127 | data = UIImageJPEGRepresentation(image, 0.4); 128 | }else 129 | if (100.0 > originalSize.width) { 130 | data = UIImageJPEGRepresentation(image, 0.5); 131 | } 132 | 133 | return data; 134 | } 135 | 136 | 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /PPVideoImage/PPVideoImageManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // PPVideoImageManager.h 3 | // 4 | // 5 | // Created by xuzhongping on 2016/12/13. 6 | // Copyright © 2016年 JungHsu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^completedBlock)(UIImage *image,NSURL *url,NSError *error); 12 | 13 | @interface PPVideoImageManager : NSObject 14 | 15 | + (instancetype)sharedManager; 16 | 17 | - (void)pp_parseImagForVideoUrl:(NSURL *)url size:(CGSize)size completed:(completedBlock)complete; 18 | - (void)pp_parseImagForVideoUrl:(NSURL *)url size:(CGSize)size cornerRadius:(CGFloat)cornerRadius completed:(completedBlock)complete; 19 | 20 | - (UIImage *)disposeCircularImage:(UIImage *)image size:(CGSize)size cornerRadius:(CGFloat)cornerRadius; 21 | @end 22 | -------------------------------------------------------------------------------- /PPVideoImage/PPVideoImageManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // PPVideoImageManager.m 3 | // 4 | // 5 | // Created by xuzhongping on 2016/12/13. 6 | // Copyright © 2016年 JungHsu. All rights reserved. 7 | // 8 | 9 | #import "PPVideoImageManager.h" 10 | #import "PPCacheUtil.h" 11 | #import 12 | 13 | #define PPBLOCK @"ppBlock" 14 | #define PPIMAGE @"ppImage" 15 | #define PPURL @"ppURL" 16 | #define PPERROR @"ppERROR" 17 | 18 | 19 | @interface PPOperationPool : NSObject 20 | { 21 | @public 22 | NSMutableDictionary *_subPoolDic; 23 | } 24 | - (void)addOperation:(NSDictionary *)operationObj; 25 | 26 | @end 27 | 28 | 29 | @implementation PPOperationPool 30 | 31 | 32 | - (instancetype)init{ 33 | if (self = [super init]) { 34 | _subPoolDic = @{}.mutableCopy; 35 | } 36 | return self; 37 | } 38 | 39 | - (void)addOperation:(NSDictionary *)operationObj{ 40 | 41 | NSString *operationKey = operationObj.allKeys.firstObject; 42 | id operationValue = operationObj.allValues.firstObject; 43 | if (![_subPoolDic valueForKey:operationKey]) { 44 | NSMutableArray *subPool = @[].mutableCopy; 45 | [_subPoolDic setValue:subPool forKey:operationKey]; 46 | } 47 | [_subPoolDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, NSMutableArray * obj, BOOL * _Nonnull stop) { 48 | if ([key isEqualToString:operationKey]) { 49 | [obj addObject:operationValue]; 50 | } 51 | }]; 52 | 53 | } 54 | @end 55 | 56 | @implementation PPVideoImageManager 57 | 58 | { 59 | NSMutableDictionary *_resultImageDict; 60 | PPOperationPool *_operationPool; 61 | void(^imageCompleteBlock)(NSMutableDictionary *operationDic); 62 | } 63 | 64 | #pragma mark - 单例 65 | static id _instance; 66 | + (id)allocWithZone:(struct _NSZone *)zone 67 | { 68 | static dispatch_once_t onceToken; 69 | dispatch_once(&onceToken, ^{ 70 | _instance = [super allocWithZone:zone]; 71 | }); 72 | return _instance; 73 | } 74 | 75 | + (instancetype)sharedManager 76 | { 77 | static dispatch_once_t onceToken; 78 | dispatch_once(&onceToken, ^{ 79 | _instance = [[self alloc] init]; 80 | }); 81 | return _instance; 82 | } 83 | 84 | - (id)copyWithZone:(NSZone *)zone 85 | { 86 | return _instance; 87 | } 88 | 89 | - (instancetype)init{ 90 | if (self = [super init]) { 91 | _resultImageDict = @{}.mutableCopy; 92 | _operationPool = [[PPOperationPool alloc]init]; 93 | } 94 | return self; 95 | } 96 | 97 | 98 | #pragma mark - public 99 | 100 | - (void)pp_parseImagForVideoUrl:(NSURL *)url size:(CGSize)size completed:(completedBlock)complete{ 101 | [self pp_parseImagForVideoUrl:url size:size cornerRadius:0 completed:complete]; 102 | } 103 | 104 | - (void)pp_parseImagForVideoUrl:(NSURL *)url size:(CGSize)size cornerRadius:(CGFloat)cornerRadius completed:(completedBlock)complete{ 105 | __weak typeof(self) weakSelf = self; 106 | if (!url){ 107 | NSError *error = [NSError errorWithDomain:@"url is nil" code:0 userInfo:nil]; 108 | complete(nil,nil,error); 109 | return; 110 | }; 111 | 112 | if (![url isKindOfClass:[NSURL class]]) { 113 | NSError *error = [NSError errorWithDomain:@"url type error" code:0 userInfo:nil]; 114 | complete(nil,nil,error); 115 | return; 116 | } 117 | 118 | 119 | NSString *urlStr = url.path; 120 | __block UIImage *targetImage; 121 | targetImage = [PPCacheUtil sharedCacheUtil].memoryCache[urlStr]; 122 | if (targetImage) { 123 | complete(targetImage,url,nil); 124 | return; 125 | } 126 | 127 | targetImage = [[PPCacheUtil sharedCacheUtil] readDiskImage:url]; 128 | if (targetImage) { 129 | complete(targetImage,url,nil); 130 | [[PPCacheUtil sharedCacheUtil].memoryCache setValue:targetImage forKey:urlStr]; 131 | return; 132 | } 133 | 134 | NSBlockOperation *operation = [PPCacheUtil sharedCacheUtil].operations[urlStr]; 135 | if (operation.isExecuting) { // 如果操作正在执行 136 | targetImage = [[PPCacheUtil sharedCacheUtil].memoryCache valueForKey:urlStr]; 137 | if (targetImage) { 138 | complete(targetImage,url,nil); return; 139 | } 140 | targetImage = [[PPCacheUtil sharedCacheUtil] readDiskImage:url]; 141 | if (targetImage) { 142 | complete(targetImage,url,nil); return; 143 | 144 | }else { // 当操作正在执行且图片资源不存在 、 将操作回调加入操作池 145 | imageCompleteBlock = ^(NSDictionary *operationDic){ 146 | NSDictionary *info = operationDic[url.path]; 147 | if (info) { 148 | complete(info[PPIMAGE],info[PPURL],nil); 149 | } 150 | }; 151 | [_operationPool addOperation:@{urlStr:imageCompleteBlock}]; return; 152 | 153 | } 154 | 155 | } 156 | 157 | operation = [NSBlockOperation blockOperationWithBlock:^{ 158 | NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; 159 | AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:opts]; 160 | AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset]; 161 | generator.appliesPreferredTrackTransform = YES; 162 | generator.maximumSize = CGSizeMake(size.width, size.height); 163 | NSError *error = nil; 164 | targetImage = [UIImage imageWithCGImage:[generator copyCGImageAtTime:CMTimeMake(0, 10) actualTime:NULL error:&error]]; 165 | if (cornerRadius) { 166 | targetImage = [self disposeCircularImage:targetImage size:size cornerRadius:cornerRadius]; 167 | } 168 | if (!error) { 169 | dispatch_async(dispatch_get_main_queue(), ^{ 170 | 171 | [weakSelf performSelector:@selector(dealImage:) withObject:@{PPBLOCK: complete,PPIMAGE:targetImage, PPURL:url} afterDelay:3.0 inModes:@[NSDefaultRunLoopMode]]; 172 | }); 173 | [[PPCacheUtil sharedCacheUtil].memoryCache setValue:targetImage forKey:urlStr]; 174 | 175 | [[PPCacheUtil sharedCacheUtil] writeDiskCache:targetImage url:url]; 176 | }else { 177 | complete(nil,url,error); 178 | } 179 | [[PPCacheUtil sharedCacheUtil].operations removeObjectForKey:url]; 180 | }]; 181 | 182 | NSOperationQueue *asyncQueue = [[NSOperationQueue alloc]init]; 183 | [asyncQueue addOperation:operation]; 184 | [[PPCacheUtil sharedCacheUtil].operations setValue:operation forKey:urlStr]; 185 | } 186 | 187 | - (void)dealImage:(id)info{ 188 | completedBlock block = info[PPBLOCK]; 189 | UIImage *image = info[PPIMAGE]; 190 | NSURL * url = info[PPURL]; 191 | block(image,url,nil); 192 | [_resultImageDict setValue:info forKey:url.path]; 193 | 194 | [_operationPool->_subPoolDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, NSMutableArray * _Nonnull subPool, BOOL * _Nonnull stop) { 195 | if ([key isEqualToString:url.path]) { 196 | for (imageCompleteBlock in subPool) { 197 | imageCompleteBlock(_resultImageDict); 198 | } 199 | *stop = YES; 200 | } 201 | }]; 202 | [_operationPool->_subPoolDic removeObjectForKey:url.path]; 203 | } 204 | 205 | #pragma mark - 处理圆角 206 | - (UIImage *)disposeCircularImage:(UIImage *)image size:(CGSize)size cornerRadius:(CGFloat)cornerRadius{ 207 | if (!cornerRadius) return image; 208 | CGRect rect = (CGRect){0.f, 0.f, size}; 209 | UIGraphicsBeginImageContextWithOptions(size, NO, UIScreen.mainScreen.scale); 210 | CGContextAddPath(UIGraphicsGetCurrentContext(), 211 | [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius].CGPath); 212 | CGContextClip(UIGraphicsGetCurrentContext()); 213 | [image drawInRect:rect]; 214 | UIImage *output = UIGraphicsGetImageFromCurrentImageContext(); 215 | UIGraphicsEndImageContext(); 216 | return output; 217 | } 218 | 219 | @end 220 | -------------------------------------------------------------------------------- /PPVideoImage/UIImageView+VideoCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+VideoCache.h 3 | // 4 | // 5 | // Created by xuzhongping on 2016/12/13. 6 | // Copyright © 2016年 JungHsu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImageView (VideoCache) 12 | 13 | - (void)pp_setImageWithVideoURL:(NSURL *)url; 14 | - (void)pp_setImageWithVideoURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 15 | - (void)pp_setImageWithVideoURL:(NSURL *)url placeholderImage:(UIImage *)placeholder cornerRadius:(CGFloat)cornerRadius; 16 | @end 17 | 18 | @interface UIButton (VideoCache) 19 | - (void)pp_setImageWithVideoURL:(NSURL *)url forState:(UIControlState)state; 20 | - (void)pp_setImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; 21 | - (void)pp_setImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder cornerRadius:(CGFloat)cornerRadius; 22 | 23 | - (void)pp_setBackgroundImageWithVideoURL:(NSURL *)url forState:(UIControlState)state; 24 | - (void)pp_setBackgroundImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; 25 | - (void)pp_setBackgroundImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder cornerRadius:(CGFloat)cornerRadius; 26 | @end 27 | -------------------------------------------------------------------------------- /PPVideoImage/UIImageView+VideoCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+VideoCache.m 3 | // 4 | // 5 | // Created by xuzhongping on 2016/12/13. 6 | // Copyright © 2016年 JungHsu. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+VideoCache.h" 10 | #import "PPVideoImageManager.h" 11 | 12 | 13 | @implementation UIImageView (VideoCache) 14 | 15 | #pragma mark - IMAGE 16 | - (void)pp_setImageWithVideoURL:(NSURL *)url{ 17 | [self pp_setImageWithVideoURL:url placeholderImage:nil]; 18 | } 19 | - (void)pp_setImageWithVideoURL:(NSURL *)url placeholderImage:(UIImage *)placeholder{ 20 | if (placeholder && [placeholder isKindOfClass:[UIImage class]]) { 21 | self.image = placeholder; 22 | } 23 | 24 | [[PPVideoImageManager sharedManager] pp_parseImagForVideoUrl:url size:self.bounds.size completed:^(UIImage *image, NSURL *url, NSError *error) { 25 | if (error || ![image isKindOfClass:[UIImage class]]) { NSAssert(false, @"%@ or image class error",error); 26 | return ; 27 | }; 28 | self.image = image; 29 | }]; 30 | 31 | 32 | } 33 | 34 | - (void)pp_setImageWithVideoURL:(NSURL *)url placeholderImage:(UIImage *)placeholder cornerRadius:(CGFloat)cornerRadius{ 35 | if (placeholder && [placeholder isKindOfClass:[UIImage class]]) { 36 | 37 | self.image = placeholder; 38 | } 39 | 40 | [[PPVideoImageManager sharedManager] pp_parseImagForVideoUrl:url size:self.bounds.size cornerRadius:cornerRadius completed:^(UIImage *image, NSURL *url, NSError *error) { 41 | if (error || ![image isKindOfClass:[UIImage class]]) { NSAssert(false, @"%@ or image class error",error); 42 | return ; 43 | }; 44 | self.image = image; 45 | }]; 46 | } 47 | 48 | @end 49 | 50 | @implementation UIButton (VideoCache) 51 | #pragma mark - BUTTONIMAGE 52 | - (void)pp_setImageWithVideoURL:(NSURL *)url forState:(UIControlState)state{ 53 | [self pp_setImageWithVideoURL:url forState:state placeholderImage:nil]; 54 | } 55 | 56 | - (void)pp_setImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder{ 57 | if (placeholder && [placeholder isKindOfClass:[UIImage class]]) { 58 | [self setImage:placeholder forState:state]; 59 | } 60 | 61 | [[PPVideoImageManager sharedManager] pp_parseImagForVideoUrl:url size:self.imageView.bounds.size completed:^(UIImage *image, NSURL *url, NSError *error) { 62 | if (error || ![image isKindOfClass:[UIImage class]]) { NSAssert(false, @"%@ or image class error",error); 63 | return ; 64 | }; 65 | [self setImage:image forState:state]; 66 | }]; 67 | } 68 | 69 | - (void)pp_setImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder cornerRadius:(CGFloat)cornerRadius{ 70 | if (placeholder && [placeholder isKindOfClass:[UIImage class]]) { 71 | [self setImage:placeholder forState:state]; 72 | } 73 | 74 | [[PPVideoImageManager sharedManager] pp_parseImagForVideoUrl:url size:self.bounds.size cornerRadius:cornerRadius completed:^(UIImage *image, NSURL *url, NSError *error) { 75 | if (error || ![image isKindOfClass:[UIImage class]]) { NSAssert(false, @"%@ or image class error",error); 76 | return ; 77 | };; 78 | [self setImage:image forState:state]; 79 | }]; 80 | } 81 | 82 | #pragma mark - BUTTONBACK 83 | - (void)pp_setBackgroundImageWithVideoURL:(NSURL *)url forState:(UIControlState)state{ 84 | [self pp_setBackgroundImageWithVideoURL:url forState:state placeholderImage:nil]; 85 | } 86 | 87 | - (void)pp_setBackgroundImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder{ 88 | if (placeholder && [placeholder isKindOfClass:[UIImage class]]) { 89 | [self setBackgroundImage:placeholder forState:state]; 90 | } 91 | [[PPVideoImageManager sharedManager] pp_parseImagForVideoUrl:url size:self.imageView.bounds.size completed:^(UIImage *image, NSURL *url, NSError *error) { 92 | if (error || ![image isKindOfClass:[UIImage class]]) { NSAssert(false, @"%@ or image class error",error); 93 | return ; 94 | }; 95 | [self setBackgroundImage:image forState:state]; 96 | }]; 97 | } 98 | 99 | - (void)pp_setBackgroundImageWithVideoURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder cornerRadius:(CGFloat)cornerRadius{ 100 | if (placeholder && [placeholder isKindOfClass:[UIImage class]]) { 101 | [self setBackgroundImage:placeholder forState:state]; 102 | } 103 | 104 | [[PPVideoImageManager sharedManager] pp_parseImagForVideoUrl:url size:self.bounds.size cornerRadius:cornerRadius completed:^(UIImage *image, NSURL *url, NSError *error) { 105 | if (error || ![image isKindOfClass:[UIImage class]]) { NSAssert(false, @"%@ or image class error",error); 106 | return ; 107 | }; 108 | [self setBackgroundImage:image forState:state]; 109 | }]; 110 | } 111 | 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C005AFDB1E00D6F70075EC29 /* PPTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C005AFD91E00D6F70075EC29 /* PPTableViewCell.m */; }; 11 | C005AFDC1E00D6F70075EC29 /* PPTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C005AFDA1E00D6F70075EC29 /* PPTableViewCell.xib */; }; 12 | ED6610801E001BAC000F7455 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ED66107F1E001BAC000F7455 /* main.m */; }; 13 | ED6610831E001BAC000F7455 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6610821E001BAC000F7455 /* AppDelegate.m */; }; 14 | ED6610861E001BAC000F7455 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6610851E001BAC000F7455 /* ViewController.m */; }; 15 | ED6610891E001BAC000F7455 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED6610871E001BAC000F7455 /* Main.storyboard */; }; 16 | ED66108B1E001BAC000F7455 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ED66108A1E001BAC000F7455 /* Assets.xcassets */; }; 17 | ED66108E1E001BAC000F7455 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ED66108C1E001BAC000F7455 /* LaunchScreen.storyboard */; }; 18 | ED6610991E001BAC000F7455 /* PPVideoImageDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6610981E001BAC000F7455 /* PPVideoImageDemoTests.m */; }; 19 | ED6610A41E001BAC000F7455 /* PPVideoImageDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6610A31E001BAC000F7455 /* PPVideoImageDemoUITests.m */; }; 20 | ED8536071EC4006D00D1E000 /* PPCacheUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = ED8536021EC4006D00D1E000 /* PPCacheUtil.m */; }; 21 | ED8536081EC4006D00D1E000 /* PPVideoImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = ED8536041EC4006D00D1E000 /* PPVideoImageManager.m */; }; 22 | ED8536091EC4006D00D1E000 /* UIImageView+VideoCache.m in Sources */ = {isa = PBXBuildFile; fileRef = ED8536061EC4006D00D1E000 /* UIImageView+VideoCache.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | ED6610951E001BAC000F7455 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = ED6610731E001BAC000F7455 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = ED66107A1E001BAC000F7455; 31 | remoteInfo = PPVideoImageDemo; 32 | }; 33 | ED6610A01E001BAC000F7455 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = ED6610731E001BAC000F7455 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = ED66107A1E001BAC000F7455; 38 | remoteInfo = PPVideoImageDemo; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | C005AFD81E00D6F70075EC29 /* PPTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPTableViewCell.h; sourceTree = ""; }; 44 | C005AFD91E00D6F70075EC29 /* PPTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPTableViewCell.m; sourceTree = ""; }; 45 | C005AFDA1E00D6F70075EC29 /* PPTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PPTableViewCell.xib; sourceTree = ""; }; 46 | ED66107B1E001BAC000F7455 /* PPVideoImageDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PPVideoImageDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | ED66107F1E001BAC000F7455 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 48 | ED6610811E001BAC000F7455 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | ED6610821E001BAC000F7455 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | ED6610841E001BAC000F7455 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 51 | ED6610851E001BAC000F7455 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 52 | ED6610881E001BAC000F7455 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | ED66108A1E001BAC000F7455 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | ED66108D1E001BAC000F7455 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | ED66108F1E001BAC000F7455 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | ED6610941E001BAC000F7455 /* PPVideoImageDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PPVideoImageDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | ED6610981E001BAC000F7455 /* PPVideoImageDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PPVideoImageDemoTests.m; sourceTree = ""; }; 58 | ED66109A1E001BAC000F7455 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | ED66109F1E001BAC000F7455 /* PPVideoImageDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PPVideoImageDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | ED6610A31E001BAC000F7455 /* PPVideoImageDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PPVideoImageDemoUITests.m; sourceTree = ""; }; 61 | ED6610A51E001BAC000F7455 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | ED8536011EC4006D00D1E000 /* PPCacheUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPCacheUtil.h; sourceTree = ""; }; 63 | ED8536021EC4006D00D1E000 /* PPCacheUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPCacheUtil.m; sourceTree = ""; }; 64 | ED8536031EC4006D00D1E000 /* PPVideoImageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPVideoImageManager.h; sourceTree = ""; }; 65 | ED8536041EC4006D00D1E000 /* PPVideoImageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPVideoImageManager.m; sourceTree = ""; }; 66 | ED8536051EC4006D00D1E000 /* UIImageView+VideoCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+VideoCache.h"; sourceTree = ""; }; 67 | ED8536061EC4006D00D1E000 /* UIImageView+VideoCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+VideoCache.m"; sourceTree = ""; }; 68 | /* End PBXFileReference section */ 69 | 70 | /* Begin PBXFrameworksBuildPhase section */ 71 | ED6610781E001BAC000F7455 /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | ED6610911E001BAC000F7455 /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | ED66109C1E001BAC000F7455 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | ED6610721E001BAC000F7455 = { 96 | isa = PBXGroup; 97 | children = ( 98 | ED8536001EC4006D00D1E000 /* PPVideoImage */, 99 | ED66107D1E001BAC000F7455 /* PPVideoImageDemo */, 100 | ED6610971E001BAC000F7455 /* PPVideoImageDemoTests */, 101 | ED6610A21E001BAC000F7455 /* PPVideoImageDemoUITests */, 102 | ED66107C1E001BAC000F7455 /* Products */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | ED66107C1E001BAC000F7455 /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | ED66107B1E001BAC000F7455 /* PPVideoImageDemo.app */, 110 | ED6610941E001BAC000F7455 /* PPVideoImageDemoTests.xctest */, 111 | ED66109F1E001BAC000F7455 /* PPVideoImageDemoUITests.xctest */, 112 | ); 113 | name = Products; 114 | sourceTree = ""; 115 | }; 116 | ED66107D1E001BAC000F7455 /* PPVideoImageDemo */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | C005AFD81E00D6F70075EC29 /* PPTableViewCell.h */, 120 | C005AFD91E00D6F70075EC29 /* PPTableViewCell.m */, 121 | C005AFDA1E00D6F70075EC29 /* PPTableViewCell.xib */, 122 | ED6610811E001BAC000F7455 /* AppDelegate.h */, 123 | ED6610821E001BAC000F7455 /* AppDelegate.m */, 124 | ED6610841E001BAC000F7455 /* ViewController.h */, 125 | ED6610851E001BAC000F7455 /* ViewController.m */, 126 | ED6610871E001BAC000F7455 /* Main.storyboard */, 127 | ED66108A1E001BAC000F7455 /* Assets.xcassets */, 128 | ED66108C1E001BAC000F7455 /* LaunchScreen.storyboard */, 129 | ED66108F1E001BAC000F7455 /* Info.plist */, 130 | ED66107E1E001BAC000F7455 /* Supporting Files */, 131 | ); 132 | path = PPVideoImageDemo; 133 | sourceTree = ""; 134 | }; 135 | ED66107E1E001BAC000F7455 /* Supporting Files */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | ED66107F1E001BAC000F7455 /* main.m */, 139 | ); 140 | name = "Supporting Files"; 141 | sourceTree = ""; 142 | }; 143 | ED6610971E001BAC000F7455 /* PPVideoImageDemoTests */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | ED6610981E001BAC000F7455 /* PPVideoImageDemoTests.m */, 147 | ED66109A1E001BAC000F7455 /* Info.plist */, 148 | ); 149 | path = PPVideoImageDemoTests; 150 | sourceTree = ""; 151 | }; 152 | ED6610A21E001BAC000F7455 /* PPVideoImageDemoUITests */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | ED6610A31E001BAC000F7455 /* PPVideoImageDemoUITests.m */, 156 | ED6610A51E001BAC000F7455 /* Info.plist */, 157 | ); 158 | path = PPVideoImageDemoUITests; 159 | sourceTree = ""; 160 | }; 161 | ED8536001EC4006D00D1E000 /* PPVideoImage */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | ED8536011EC4006D00D1E000 /* PPCacheUtil.h */, 165 | ED8536021EC4006D00D1E000 /* PPCacheUtil.m */, 166 | ED8536031EC4006D00D1E000 /* PPVideoImageManager.h */, 167 | ED8536041EC4006D00D1E000 /* PPVideoImageManager.m */, 168 | ED8536051EC4006D00D1E000 /* UIImageView+VideoCache.h */, 169 | ED8536061EC4006D00D1E000 /* UIImageView+VideoCache.m */, 170 | ); 171 | path = PPVideoImage; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXGroup section */ 175 | 176 | /* Begin PBXNativeTarget section */ 177 | ED66107A1E001BAC000F7455 /* PPVideoImageDemo */ = { 178 | isa = PBXNativeTarget; 179 | buildConfigurationList = ED6610A81E001BAC000F7455 /* Build configuration list for PBXNativeTarget "PPVideoImageDemo" */; 180 | buildPhases = ( 181 | ED6610771E001BAC000F7455 /* Sources */, 182 | ED6610781E001BAC000F7455 /* Frameworks */, 183 | ED6610791E001BAC000F7455 /* Resources */, 184 | ); 185 | buildRules = ( 186 | ); 187 | dependencies = ( 188 | ); 189 | name = PPVideoImageDemo; 190 | productName = PPVideoImageDemo; 191 | productReference = ED66107B1E001BAC000F7455 /* PPVideoImageDemo.app */; 192 | productType = "com.apple.product-type.application"; 193 | }; 194 | ED6610931E001BAC000F7455 /* PPVideoImageDemoTests */ = { 195 | isa = PBXNativeTarget; 196 | buildConfigurationList = ED6610AB1E001BAC000F7455 /* Build configuration list for PBXNativeTarget "PPVideoImageDemoTests" */; 197 | buildPhases = ( 198 | ED6610901E001BAC000F7455 /* Sources */, 199 | ED6610911E001BAC000F7455 /* Frameworks */, 200 | ED6610921E001BAC000F7455 /* Resources */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | ED6610961E001BAC000F7455 /* PBXTargetDependency */, 206 | ); 207 | name = PPVideoImageDemoTests; 208 | productName = PPVideoImageDemoTests; 209 | productReference = ED6610941E001BAC000F7455 /* PPVideoImageDemoTests.xctest */; 210 | productType = "com.apple.product-type.bundle.unit-test"; 211 | }; 212 | ED66109E1E001BAC000F7455 /* PPVideoImageDemoUITests */ = { 213 | isa = PBXNativeTarget; 214 | buildConfigurationList = ED6610AE1E001BAC000F7455 /* Build configuration list for PBXNativeTarget "PPVideoImageDemoUITests" */; 215 | buildPhases = ( 216 | ED66109B1E001BAC000F7455 /* Sources */, 217 | ED66109C1E001BAC000F7455 /* Frameworks */, 218 | ED66109D1E001BAC000F7455 /* Resources */, 219 | ); 220 | buildRules = ( 221 | ); 222 | dependencies = ( 223 | ED6610A11E001BAC000F7455 /* PBXTargetDependency */, 224 | ); 225 | name = PPVideoImageDemoUITests; 226 | productName = PPVideoImageDemoUITests; 227 | productReference = ED66109F1E001BAC000F7455 /* PPVideoImageDemoUITests.xctest */; 228 | productType = "com.apple.product-type.bundle.ui-testing"; 229 | }; 230 | /* End PBXNativeTarget section */ 231 | 232 | /* Begin PBXProject section */ 233 | ED6610731E001BAC000F7455 /* Project object */ = { 234 | isa = PBXProject; 235 | attributes = { 236 | LastUpgradeCheck = 0800; 237 | ORGANIZATIONNAME = "徐仲平"; 238 | TargetAttributes = { 239 | ED66107A1E001BAC000F7455 = { 240 | CreatedOnToolsVersion = 8.0; 241 | ProvisioningStyle = Automatic; 242 | }; 243 | ED6610931E001BAC000F7455 = { 244 | CreatedOnToolsVersion = 8.0; 245 | DevelopmentTeam = 94Z9LKE2W7; 246 | ProvisioningStyle = Automatic; 247 | TestTargetID = ED66107A1E001BAC000F7455; 248 | }; 249 | ED66109E1E001BAC000F7455 = { 250 | CreatedOnToolsVersion = 8.0; 251 | DevelopmentTeam = 94Z9LKE2W7; 252 | ProvisioningStyle = Automatic; 253 | TestTargetID = ED66107A1E001BAC000F7455; 254 | }; 255 | }; 256 | }; 257 | buildConfigurationList = ED6610761E001BAC000F7455 /* Build configuration list for PBXProject "PPVideoImageDemo" */; 258 | compatibilityVersion = "Xcode 3.2"; 259 | developmentRegion = English; 260 | hasScannedForEncodings = 0; 261 | knownRegions = ( 262 | en, 263 | Base, 264 | ); 265 | mainGroup = ED6610721E001BAC000F7455; 266 | productRefGroup = ED66107C1E001BAC000F7455 /* Products */; 267 | projectDirPath = ""; 268 | projectRoot = ""; 269 | targets = ( 270 | ED66107A1E001BAC000F7455 /* PPVideoImageDemo */, 271 | ED6610931E001BAC000F7455 /* PPVideoImageDemoTests */, 272 | ED66109E1E001BAC000F7455 /* PPVideoImageDemoUITests */, 273 | ); 274 | }; 275 | /* End PBXProject section */ 276 | 277 | /* Begin PBXResourcesBuildPhase section */ 278 | ED6610791E001BAC000F7455 /* Resources */ = { 279 | isa = PBXResourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | ED66108E1E001BAC000F7455 /* LaunchScreen.storyboard in Resources */, 283 | ED66108B1E001BAC000F7455 /* Assets.xcassets in Resources */, 284 | ED6610891E001BAC000F7455 /* Main.storyboard in Resources */, 285 | C005AFDC1E00D6F70075EC29 /* PPTableViewCell.xib in Resources */, 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | ED6610921E001BAC000F7455 /* Resources */ = { 290 | isa = PBXResourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | ED66109D1E001BAC000F7455 /* Resources */ = { 297 | isa = PBXResourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | /* End PBXResourcesBuildPhase section */ 304 | 305 | /* Begin PBXSourcesBuildPhase section */ 306 | ED6610771E001BAC000F7455 /* Sources */ = { 307 | isa = PBXSourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | ED6610861E001BAC000F7455 /* ViewController.m in Sources */, 311 | C005AFDB1E00D6F70075EC29 /* PPTableViewCell.m in Sources */, 312 | ED8536071EC4006D00D1E000 /* PPCacheUtil.m in Sources */, 313 | ED6610831E001BAC000F7455 /* AppDelegate.m in Sources */, 314 | ED8536091EC4006D00D1E000 /* UIImageView+VideoCache.m in Sources */, 315 | ED6610801E001BAC000F7455 /* main.m in Sources */, 316 | ED8536081EC4006D00D1E000 /* PPVideoImageManager.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | ED6610901E001BAC000F7455 /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ED6610991E001BAC000F7455 /* PPVideoImageDemoTests.m in Sources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | ED66109B1E001BAC000F7455 /* Sources */ = { 329 | isa = PBXSourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | ED6610A41E001BAC000F7455 /* PPVideoImageDemoUITests.m in Sources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXSourcesBuildPhase section */ 337 | 338 | /* Begin PBXTargetDependency section */ 339 | ED6610961E001BAC000F7455 /* PBXTargetDependency */ = { 340 | isa = PBXTargetDependency; 341 | target = ED66107A1E001BAC000F7455 /* PPVideoImageDemo */; 342 | targetProxy = ED6610951E001BAC000F7455 /* PBXContainerItemProxy */; 343 | }; 344 | ED6610A11E001BAC000F7455 /* PBXTargetDependency */ = { 345 | isa = PBXTargetDependency; 346 | target = ED66107A1E001BAC000F7455 /* PPVideoImageDemo */; 347 | targetProxy = ED6610A01E001BAC000F7455 /* PBXContainerItemProxy */; 348 | }; 349 | /* End PBXTargetDependency section */ 350 | 351 | /* Begin PBXVariantGroup section */ 352 | ED6610871E001BAC000F7455 /* Main.storyboard */ = { 353 | isa = PBXVariantGroup; 354 | children = ( 355 | ED6610881E001BAC000F7455 /* Base */, 356 | ); 357 | name = Main.storyboard; 358 | sourceTree = ""; 359 | }; 360 | ED66108C1E001BAC000F7455 /* LaunchScreen.storyboard */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | ED66108D1E001BAC000F7455 /* Base */, 364 | ); 365 | name = LaunchScreen.storyboard; 366 | sourceTree = ""; 367 | }; 368 | /* End PBXVariantGroup section */ 369 | 370 | /* Begin XCBuildConfiguration section */ 371 | ED6610A61E001BAC000F7455 /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | CLANG_ANALYZER_NONNULL = YES; 376 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 377 | CLANG_CXX_LIBRARY = "libc++"; 378 | CLANG_ENABLE_MODULES = YES; 379 | CLANG_ENABLE_OBJC_ARC = YES; 380 | CLANG_WARN_BOOL_CONVERSION = YES; 381 | CLANG_WARN_CONSTANT_CONVERSION = YES; 382 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 383 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INFINITE_RECURSION = YES; 387 | CLANG_WARN_INT_CONVERSION = YES; 388 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 389 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 390 | CLANG_WARN_UNREACHABLE_CODE = YES; 391 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 392 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 393 | COPY_PHASE_STRIP = NO; 394 | DEBUG_INFORMATION_FORMAT = dwarf; 395 | ENABLE_STRICT_OBJC_MSGSEND = YES; 396 | ENABLE_TESTABILITY = YES; 397 | GCC_C_LANGUAGE_STANDARD = gnu99; 398 | GCC_DYNAMIC_NO_PIC = NO; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_OPTIMIZATION_LEVEL = 0; 401 | GCC_PREPROCESSOR_DEFINITIONS = ( 402 | "DEBUG=1", 403 | "$(inherited)", 404 | ); 405 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 407 | GCC_WARN_UNDECLARED_SELECTOR = YES; 408 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 409 | GCC_WARN_UNUSED_FUNCTION = YES; 410 | GCC_WARN_UNUSED_VARIABLE = YES; 411 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 412 | MTL_ENABLE_DEBUG_INFO = YES; 413 | ONLY_ACTIVE_ARCH = YES; 414 | SDKROOT = iphoneos; 415 | }; 416 | name = Debug; 417 | }; 418 | ED6610A71E001BAC000F7455 /* Release */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | ALWAYS_SEARCH_USER_PATHS = NO; 422 | CLANG_ANALYZER_NONNULL = YES; 423 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 424 | CLANG_CXX_LIBRARY = "libc++"; 425 | CLANG_ENABLE_MODULES = YES; 426 | CLANG_ENABLE_OBJC_ARC = YES; 427 | CLANG_WARN_BOOL_CONVERSION = YES; 428 | CLANG_WARN_CONSTANT_CONVERSION = YES; 429 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 430 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 431 | CLANG_WARN_EMPTY_BODY = YES; 432 | CLANG_WARN_ENUM_CONVERSION = YES; 433 | CLANG_WARN_INFINITE_RECURSION = YES; 434 | CLANG_WARN_INT_CONVERSION = YES; 435 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 436 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 437 | CLANG_WARN_UNREACHABLE_CODE = YES; 438 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 439 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 440 | COPY_PHASE_STRIP = NO; 441 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 442 | ENABLE_NS_ASSERTIONS = NO; 443 | ENABLE_STRICT_OBJC_MSGSEND = YES; 444 | GCC_C_LANGUAGE_STANDARD = gnu99; 445 | GCC_NO_COMMON_BLOCKS = YES; 446 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 447 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 448 | GCC_WARN_UNDECLARED_SELECTOR = YES; 449 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 450 | GCC_WARN_UNUSED_FUNCTION = YES; 451 | GCC_WARN_UNUSED_VARIABLE = YES; 452 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 453 | MTL_ENABLE_DEBUG_INFO = NO; 454 | SDKROOT = iphoneos; 455 | VALIDATE_PRODUCT = YES; 456 | }; 457 | name = Release; 458 | }; 459 | ED6610A91E001BAC000F7455 /* Debug */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | DEVELOPMENT_TEAM = ""; 464 | INFOPLIST_FILE = PPVideoImageDemo/Info.plist; 465 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 467 | PRODUCT_BUNDLE_IDENTIFIER = junghsu.PPVideoImageDemo; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | TARGETED_DEVICE_FAMILY = 1; 470 | }; 471 | name = Debug; 472 | }; 473 | ED6610AA1E001BAC000F7455 /* Release */ = { 474 | isa = XCBuildConfiguration; 475 | buildSettings = { 476 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 477 | DEVELOPMENT_TEAM = ""; 478 | INFOPLIST_FILE = PPVideoImageDemo/Info.plist; 479 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 480 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 481 | PRODUCT_BUNDLE_IDENTIFIER = junghsu.PPVideoImageDemo; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | TARGETED_DEVICE_FAMILY = 1; 484 | }; 485 | name = Release; 486 | }; 487 | ED6610AC1E001BAC000F7455 /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | BUNDLE_LOADER = "$(TEST_HOST)"; 491 | DEVELOPMENT_TEAM = 94Z9LKE2W7; 492 | INFOPLIST_FILE = PPVideoImageDemoTests/Info.plist; 493 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 494 | PRODUCT_BUNDLE_IDENTIFIER = junghsu.PPVideoImageDemoTests; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PPVideoImageDemo.app/PPVideoImageDemo"; 497 | }; 498 | name = Debug; 499 | }; 500 | ED6610AD1E001BAC000F7455 /* Release */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | BUNDLE_LOADER = "$(TEST_HOST)"; 504 | DEVELOPMENT_TEAM = 94Z9LKE2W7; 505 | INFOPLIST_FILE = PPVideoImageDemoTests/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = junghsu.PPVideoImageDemoTests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PPVideoImageDemo.app/PPVideoImageDemo"; 510 | }; 511 | name = Release; 512 | }; 513 | ED6610AF1E001BAC000F7455 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | DEVELOPMENT_TEAM = 94Z9LKE2W7; 517 | INFOPLIST_FILE = PPVideoImageDemoUITests/Info.plist; 518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 519 | PRODUCT_BUNDLE_IDENTIFIER = junghsu.PPVideoImageDemoUITests; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | TEST_TARGET_NAME = PPVideoImageDemo; 522 | }; 523 | name = Debug; 524 | }; 525 | ED6610B01E001BAC000F7455 /* Release */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | DEVELOPMENT_TEAM = 94Z9LKE2W7; 529 | INFOPLIST_FILE = PPVideoImageDemoUITests/Info.plist; 530 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 531 | PRODUCT_BUNDLE_IDENTIFIER = junghsu.PPVideoImageDemoUITests; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | TEST_TARGET_NAME = PPVideoImageDemo; 534 | }; 535 | name = Release; 536 | }; 537 | /* End XCBuildConfiguration section */ 538 | 539 | /* Begin XCConfigurationList section */ 540 | ED6610761E001BAC000F7455 /* Build configuration list for PBXProject "PPVideoImageDemo" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | ED6610A61E001BAC000F7455 /* Debug */, 544 | ED6610A71E001BAC000F7455 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | ED6610A81E001BAC000F7455 /* Build configuration list for PBXNativeTarget "PPVideoImageDemo" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | ED6610A91E001BAC000F7455 /* Debug */, 553 | ED6610AA1E001BAC000F7455 /* Release */, 554 | ); 555 | defaultConfigurationIsVisible = 0; 556 | defaultConfigurationName = Release; 557 | }; 558 | ED6610AB1E001BAC000F7455 /* Build configuration list for PBXNativeTarget "PPVideoImageDemoTests" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | ED6610AC1E001BAC000F7455 /* Debug */, 562 | ED6610AD1E001BAC000F7455 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | ED6610AE1E001BAC000F7455 /* Build configuration list for PBXNativeTarget "PPVideoImageDemoUITests" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | ED6610AF1E001BAC000F7455 /* Debug */, 571 | ED6610B01E001BAC000F7455 /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | /* End XCConfigurationList section */ 577 | }; 578 | rootObject = ED6610731E001BAC000F7455 /* Project object */; 579 | } 580 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/project.xcworkspace/xcuserdata/junghsu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuzhongping/PPVideoImage/8ec30a14cc0075a0791aca8a9188a94384262d9b/PPVideoImageDemo.xcodeproj/project.xcworkspace/xcuserdata/junghsu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/project.xcworkspace/xcuserdata/xuzhongping.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuzhongping/PPVideoImage/8ec30a14cc0075a0791aca8a9188a94384262d9b/PPVideoImageDemo.xcodeproj/project.xcworkspace/xcuserdata/xuzhongping.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/xcuserdata/junghsu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/xcuserdata/junghsu.xcuserdatad/xcschemes/PPVideoImageDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/xcuserdata/junghsu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PPVideoImageDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | ED66107A1E001BAC000F7455 16 | 17 | primary 18 | 19 | 20 | ED6610931E001BAC000F7455 21 | 22 | primary 23 | 24 | 25 | ED66109E1E001BAC000F7455 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/xcuserdata/xuzhongping.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/xcuserdata/xuzhongping.xcuserdatad/xcschemes/PPVideoImageDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /PPVideoImageDemo.xcodeproj/xcuserdata/xuzhongping.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PPVideoImageDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | ED66107A1E001BAC000F7455 16 | 17 | primary 18 | 19 | 20 | ED6610931E001BAC000F7455 21 | 22 | primary 23 | 24 | 25 | ED66109E1E001BAC000F7455 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PPVideoImageDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /PPVideoImageDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /PPVideoImageDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /PPVideoImageDemo/Assets.xcassets/no_picture.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "no_picture@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "no_picture@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /PPVideoImageDemo/Assets.xcassets/no_picture.imageset/no_picture@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuzhongping/PPVideoImage/8ec30a14cc0075a0791aca8a9188a94384262d9b/PPVideoImageDemo/Assets.xcassets/no_picture.imageset/no_picture@2x.png -------------------------------------------------------------------------------- /PPVideoImageDemo/Assets.xcassets/no_picture.imageset/no_picture@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuzhongping/PPVideoImage/8ec30a14cc0075a0791aca8a9188a94384262d9b/PPVideoImageDemo/Assets.xcassets/no_picture.imageset/no_picture@3x.png -------------------------------------------------------------------------------- /PPVideoImageDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PPVideoImageDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /PPVideoImageDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSAppTransportSecurity 24 | 25 | NSAllowsArbitraryLoads 26 | 27 | 28 | UILaunchStoryboardName 29 | LaunchScreen 30 | UIMainStoryboardFile 31 | Main 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /PPVideoImageDemo/PPTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // PPTableViewCell.h 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PPTableViewCell : UITableViewCell 12 | @property (weak, nonatomic) IBOutlet UIImageView *imageViewOne; 13 | @property (weak, nonatomic) IBOutlet UIImageView *imageViewtwo; 14 | @property (weak, nonatomic) IBOutlet UIImageView *imageViewThree; 15 | @end 16 | -------------------------------------------------------------------------------- /PPVideoImageDemo/PPTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // PPTableViewCell.m 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import "PPTableViewCell.h" 10 | 11 | @implementation PPTableViewCell 12 | 13 | - (void)awakeFromNib { 14 | [super awakeFromNib]; 15 | // Initialization code 16 | } 17 | 18 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 19 | [super setSelected:selected animated:animated]; 20 | 21 | // Configure the view for the selected state 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /PPVideoImageDemo/PPTableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /PPVideoImageDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /PPVideoImageDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIImageView+VideoCache.h" 11 | #import "PPTableViewCell.h" 12 | 13 | 14 | @interface ViewController () 15 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 16 | 17 | @property (nonatomic, strong) NSMutableArray *array; 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | static NSString *ID = @"ID"; 23 | - (NSMutableArray *)array{ 24 | if (!_array) { 25 | _array = @[].mutableCopy; 26 | } 27 | return _array; 28 | } 29 | 30 | - (void)viewDidLoad { 31 | [super viewDidLoad]; 32 | 33 | 34 | [self.tableView registerNib:[UINib nibWithNibName:@"PPTableViewCell" bundle:nil] forCellReuseIdentifier:ID]; 35 | self.tableView.rowHeight = 200; 36 | for (NSInteger i = 0; i < 100; i++ ) { 37 | [self.array addObject:@(i)]; 38 | 39 | } 40 | 41 | // self.navigationController.navigationBar.subviews.firstObject.subviews.firstObject.hidden = YES; 42 | } 43 | 44 | 45 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 46 | return self.array.count; 47 | } 48 | 49 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 50 | PPTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 51 | 52 | 53 | [cell.imageViewOne pp_setImageWithVideoURL:[NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"] placeholderImage:[UIImage imageNamed:@"no_picture"] cornerRadius:80.0]; 54 | 55 | [cell.imageViewtwo pp_setImageWithVideoURL:[NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"] placeholderImage:[UIImage imageNamed:@"no_picture"] cornerRadius:80.0]; 56 | [cell.imageViewThree pp_setImageWithVideoURL:[NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"] placeholderImage:[UIImage imageNamed:@"no_picture"] cornerRadius:80.0]; 57 | 58 | return cell; 59 | } 60 | @end 61 | -------------------------------------------------------------------------------- /PPVideoImageDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PPVideoImageDemo 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PPVideoImageDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PPVideoImageDemoTests/PPVideoImageDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PPVideoImageDemoTests.m 3 | // PPVideoImageDemoTests 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PPVideoImageDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PPVideoImageDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /PPVideoImageDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PPVideoImageDemoUITests/PPVideoImageDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PPVideoImageDemoUITests.m 3 | // PPVideoImageDemoUITests 4 | // 5 | // Created by 徐仲平 on 2016/12/13. 6 | // Copyright © 2016年 徐仲平. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PPVideoImageDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PPVideoImageDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PPVideoImage 2 | * 快速设置视频第一帧图片为ImageView的图片,支持传入一个视频URL,使用方式和SDWebImage类似 3 | * 支持磁盘缓存与内存缓存 4 | * 支持设置图片圆角 5 | 6 | #### 使用如下: 7 | 8 | ``` 9 | [cell.imageViewOne pp_setImageWithVideoURL:[NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"] placeholderImage:[UIImage imageNamed:@"no_picture"] cornerRadius:80.0]; 10 | 11 | ``` 12 | 13 | 14 | ![Aaron Swartz](https://github.com/JungHsu/PPVideoImage/blob/master/videodemo.gif) 15 | 16 | 17 | 18 | > 第一次进入时加载出的图片会有混合图层,以后打开就没有这种情况,如果你有好的解决方案请使劲提lssues或者Pull request 19 | 20 | > 希望能得到大家的反馈和建议 21 | 22 | > QQ:1021057927 23 | -------------------------------------------------------------------------------- /videodemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuzhongping/PPVideoImage/8ec30a14cc0075a0791aca8a9188a94384262d9b/videodemo.gif --------------------------------------------------------------------------------