File tree 1 file changed +3
-2
lines changed
SDWebImageVideoCoder/Classes
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 13
13
#endif
14
14
15
15
#define AVDataAssetClass @" AVDataAsset"
16
+ #define AVDataAssetMaxLength 1048576
16
17
@protocol AVDataAssetProtocol <NSObject >
17
18
18
19
- (instancetype )initWithData : (NSData *)data contentType : (AVFileType)type ;
@@ -34,7 +35,8 @@ + (instancetype)sd_assetImageGeneratorWithVideoData:(NSData *)data contentType:(
34
35
35
36
AVAsset *asset;
36
37
Class cls = NSClassFromString (AVDataAssetClass);
37
- if (type.length > 0 && [cls instancesRespondToSelector: @selector (initWithData:contentType: )]) {
38
+ if ([cls instancesRespondToSelector: @selector (initWithData:contentType: )] && data.length < AVDataAssetMaxLength && type.length > 0 ) {
39
+ // Prefer Data Asset if available
38
40
asset = [[cls alloc ] initWithData: data contentType: type];
39
41
} else {
40
42
// Random file name
@@ -48,7 +50,6 @@ + (instancetype)sd_assetImageGeneratorWithVideoData:(NSData *)data contentType:(
48
50
NSURL *fileURL = [NSURL fileURLWithPath: [NSTemporaryDirectory () stringByAppendingPathComponent: fileName]];
49
51
[data writeToURL: fileURL atomically: NO ];
50
52
asset = [[AVURLAsset alloc ] initWithURL: fileURL options: nil ];
51
- [NSFileManager .defaultManager removeItemAtURL: fileURL error: nil ];
52
53
}
53
54
if (!asset) {
54
55
return nil ;
You can’t perform that action at this time.
0 commit comments