@@ -51,7 +51,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
5151
5252 func dismissComplete( ) {
5353 DispatchQueue . main. async {
54- self . getTopMostViewController ( ) ? . dismiss ( animated: true , completion: nil )
54+ self . getTopMostViewController ( ) ? . dismiss ( animated: true , completion: nil )
5555 }
5656 }
5757
@@ -108,7 +108,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
108108 let mediaType = self . options [ " mediaType " ] as! String ;
109109
110110 MultipleImagePickerConfigure . mediaType = mediaType == " video " ? PHAssetMediaType . video : mediaType == " image " ? PHAssetMediaType . image : nil ;
111-
111+
112112 MultipleImagePickerConfigure . nibSet = ( nibName: " Cell " , bundle: MultipleImagePickerBundle . bundle ( ) )
113113
114114 // configure.allowedPhotograph = self.options["allowedPhotograph"]
@@ -143,7 +143,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
143143 }
144144
145145 func createAttachmentResponse( filePath: String ? , withFilename filename: String ? , withType type: String ? , withAsset asset: PHAsset , withTLAsset TLAsset: TLPHAsset ) -> [ AnyHashable : Any ] ? {
146-
146+ print ( " asets: " , asset , TLAsset )
147147 var media = [
148148 " path " : " file:// " + filePath! as String ,
149149 " localIdentifier " : asset. localIdentifier,
@@ -155,9 +155,21 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
155155 " type " : asset. mediaType == . video ? " video " : " image "
156156 ] as [ String : Any ]
157157
158- if ( asset. mediaType == . video && options [ " isExportThumbnail " ] as! Bool ) {
159- let thumbnail = getThumbnail ( from: filePath!, in: 0.1 )
160- media [ " thumbnail " ] = thumbnail
158+ //option in video
159+ if ( asset. mediaType == . video) {
160+ //get video's thumbnail
161+ if ( options [ " isExportThumbnail " ] as! Bool ) {
162+ let thumbnail = getThumbnail ( from: filePath!, in: 0.1 )
163+ media [ " thumbnail " ] = thumbnail
164+ }
165+ //get video size
166+ TLAsset . videoSize { Int in
167+ media [ " size " ] = Int
168+ }
169+ } else {
170+ TLAsset . photoSize { Int in
171+ media [ " size " ] = Int
172+ }
161173 }
162174 return media
163175 }
@@ -197,23 +209,6 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
197209
198210 }
199211
200- // func resizedImage(at url: URL, for size: CGSize) -> UIImage? {
201- // let options: [CFString: Any] = [
202- // kCGImageSourceCreateThumbnailFromImageIfAbsent: true,
203- // kCGImageSourceCreateThumbnailWithTransform: true,
204- // kCGImageSourceShouldCacheImmediately: true,
205- // kCGImageSourceThumbnailMaxPixelSize: max(size.width, size.height)
206- // ]
207- //
208- // guard let imageSource = CGImageSourceCreateWithURL(url as NSURL, nil),
209- // let image = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options as CFDictionary)
210- // else {
211- // return nil
212- // }
213- //
214- // return UIImage(cgImage: image)
215- // }
216-
217212 func dismissPhotoPicker( withTLPHAssets: [ TLPHAsset ] ) {
218213 if ( withTLPHAssets. count == 0 ) {
219214 self . resolve ( [ ] ) ;
@@ -226,6 +221,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
226221 if ( withTLPHAssetsCount == selectedAssetsCount && withTLPHAssets [ withTLPHAssetsCount - 1 ] . phAsset? . localIdentifier == self . selectedAssets [ selectedAssetsCount- 1 ] . phAsset? . localIdentifier) {
227222 return ;
228223 }
224+
229225 let selections = NSMutableArray . init ( array: withTLPHAssets) ;
230226 self . selectedAssets = withTLPHAssets
231227 //imageRequestOptions
@@ -240,7 +236,14 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
240236 group. enter ( )
241237 let asset = TLAsset . phAsset
242238 let index = TLAsset . selectedOrder - 1 ;
243- TLAsset . tempCopyMediaFile ( videoRequestOptions: nil , imageRequestOptions: imageRequestOptions, livePhotoRequestOptions: nil , exportPreset: AVAssetExportPresetHighestQuality, convertLivePhotosToJPG: true , progressBlock: { ( Double) in
239+
240+ let videoRequestOptions = PHVideoRequestOptions . init ( )
241+ videoRequestOptions. version = PHVideoRequestOptionsVersion . current
242+ videoRequestOptions. deliveryMode = PHVideoRequestOptionsDeliveryMode . automatic
243+ videoRequestOptions. isNetworkAccessAllowed = true
244+
245+ TLAsset . tempCopyMediaFile ( videoRequestOptions: videoRequestOptions, imageRequestOptions: imageRequestOptions, livePhotoRequestOptions: nil , exportPreset: AVAssetExportPresetHighestQuality, convertLivePhotosToJPG: true , progressBlock: { ( Double) in
246+ print ( " progressBlock: " , Double)
244247
245248 } , completionBlock: { ( filePath, fileType) in
246249 let object = NSDictionary ( dictionary: self . createAttachmentResponse (
0 commit comments