Skip to content
This repository was archived by the owner on Dec 2, 2019. It is now read-only.

Commit 1a9d192

Browse files
committed
Fix indent
1 parent 2d3acf2 commit 1a9d192

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

ios/RNThumbnail.m

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,42 @@ - (dispatch_queue_t)methodQueue
1515
RCT_EXPORT_METHOD(get:(NSString *)filepath timestamp:(NSNumber * __nonnull)timestamp resolve:(RCTPromiseResolveBlock)resolve
1616
reject:(RCTPromiseRejectBlock)reject)
1717
{
18-
@try {
19-
filepath = [filepath stringByReplacingOccurrencesOfString:@"file://"
18+
@try {
19+
filepath = [filepath stringByReplacingOccurrencesOfString:@"file://"
2020
withString:@""];
21-
NSURL *vidURL = [NSURL fileURLWithPath:filepath];
21+
NSURL *vidURL = [NSURL fileURLWithPath:filepath];
2222

23-
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:vidURL options:nil];
24-
int64_t value = 0;
25-
if (timestamp != 0) {
26-
AVAssetTrack * videoAssetTrack = [asset tracksWithMediaType: AVMediaTypeVideo].firstObject;
27-
value = [timestamp longLongValue] * videoAssetTrack.nominalFrameRate;
28-
}
23+
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:vidURL options:nil];
24+
int64_t value = 0;
25+
if (timestamp != 0) {
26+
AVAssetTrack * videoAssetTrack = [asset tracksWithMediaType: AVMediaTypeVideo].firstObject;
27+
value = [timestamp longLongValue] * videoAssetTrack.nominalFrameRate;
28+
}
2929

30-
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
31-
generator.appliesPreferredTrackTransform = YES;
30+
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
31+
generator.appliesPreferredTrackTransform = YES;
3232

33-
NSError *err = NULL;
34-
CMTime time = CMTimeMake(value, 60);
33+
NSError *err = NULL;
34+
CMTime time = CMTimeMake(value, 60);
3535

36-
CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:&err];
37-
UIImage *thumbnail = [UIImage imageWithCGImage:imgRef];
38-
// save to temp directory
39-
NSString* tempDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
36+
CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:&err];
37+
UIImage *thumbnail = [UIImage imageWithCGImage:imgRef];
38+
// save to temp directory
39+
NSString* tempDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
4040
NSUserDomainMask,
4141
YES) lastObject];
4242

43-
NSData *data = UIImageJPEGRepresentation(thumbnail, 1.0);
44-
NSFileManager *fileManager = [NSFileManager defaultManager];
45-
NSString *fullPath = [tempDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"thumb-%@.jpg", [[NSProcessInfo processInfo] globallyUniqueString]]];
46-
[fileManager createFileAtPath:fullPath contents:data attributes:nil];
47-
if (resolve)
48-
resolve(@{ @"path" : fullPath,
49-
@"width" : [NSNumber numberWithFloat: thumbnail.size.width],
50-
@"height" : [NSNumber numberWithFloat: thumbnail.size.height] });
51-
} @catch(NSException *e) {
52-
reject(e.reason, nil, nil);
53-
}
43+
NSData *data = UIImageJPEGRepresentation(thumbnail, 1.0);
44+
NSFileManager *fileManager = [NSFileManager defaultManager];
45+
NSString *fullPath = [tempDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"thumb-%@.jpg", [[NSProcessInfo processInfo] globallyUniqueString]]];
46+
[fileManager createFileAtPath:fullPath contents:data attributes:nil];
47+
if (resolve)
48+
resolve(@{ @"path" : fullPath,
49+
@"width" : [NSNumber numberWithFloat: thumbnail.size.width],
50+
@"height" : [NSNumber numberWithFloat: thumbnail.size.height] });
51+
} @catch(NSException *e) {
52+
reject(e.reason, nil, nil);
53+
}
5454
}
5555

5656
@end
57-
58-

0 commit comments

Comments
 (0)