From 0628eaec6772ba87479110e309cab617b9a5fce7 Mon Sep 17 00:00:00 2001 From: Nivetha Singara Vadivelu Date: Fri, 14 Jul 2017 17:33:52 -0700 Subject: [PATCH] Adding video play duration for camera roll Reviewed By: zjj010104 Differential Revision: D5427454 fbshipit-source-id: 49b9fb2acf8f5093257780c927720776f3fae286 --- CameraRoll.js | 3 +++ RCTCameraRollManager.m | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/CameraRoll.js b/CameraRoll.js index b66a3f30e..504878735 100644 --- a/CameraRoll.js +++ b/CameraRoll.js @@ -88,6 +88,9 @@ const getPhotosReturnChecker = createStrictShapeTypeChecker({ height: PropTypes.number.isRequired, width: PropTypes.number.isRequired, isStored: PropTypes.bool, + // TODO (nivethavadivelu) Need to add changes to Android before + // setting it as required + playableDuration: PropTypes.number, }).isRequired, timestamp: PropTypes.number.isRequired, location: createStrictShapeTypeChecker({ diff --git a/RCTCameraRollManager.m b/RCTCameraRollManager.m index 015319190..f8e6346df 100644 --- a/RCTCameraRollManager.m +++ b/RCTCameraRollManager.m @@ -187,6 +187,11 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params CLLocation *loc = [result valueForProperty:ALAssetPropertyLocation]; NSDate *date = [result valueForProperty:ALAssetPropertyDate]; NSString *filename = [result defaultRepresentation].filename; + int64_t duration = 0; + if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { + duration = [[result valueForProperty:ALAssetPropertyDuration] intValue]; + } + [assets addObject:@{ @"node": @{ @"type": [result valueForProperty:ALAssetPropertyType], @@ -197,6 +202,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params @"height": @(dimensions.height), @"width": @(dimensions.width), @"isStored": @YES, + @"playableDuration": @(duration), }, @"timestamp": @(date.timeIntervalSince1970), @"location": loc ? @{