From 636a21b67e8bc1ec254abe8c4bb2ea740e7652a4 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 --- Libraries/CameraRoll/CameraRoll.js | 3 +++ Libraries/CameraRoll/RCTCameraRollManager.m | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/Libraries/CameraRoll/CameraRoll.js b/Libraries/CameraRoll/CameraRoll.js index b66a3f30e..504878735 100644 --- a/Libraries/CameraRoll/CameraRoll.js +++ b/Libraries/CameraRoll/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/Libraries/CameraRoll/RCTCameraRollManager.m b/Libraries/CameraRoll/RCTCameraRollManager.m index 015319190..f8e6346df 100644 --- a/Libraries/CameraRoll/RCTCameraRollManager.m +++ b/Libraries/CameraRoll/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 ? @{