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 ? @{