File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ func makeValidUri(filePath: String) -> String {
265265 . appendingPathExtension ( " mp4 " )
266266 tmpURL = URL ( string: makeValidUri ( filePath: tmpURL. absoluteString) ) !
267267
268- let maxSize = 640.0 ;
268+ let maxSize : Float = options [ " maxSize " ] as! Float ;
269269 var _bitRate = bitRate;
270270 let asset = AVAsset ( url: url)
271271 guard asset. tracks. count >= 1 else {
Original file line number Diff line number Diff line change @@ -68,7 +68,11 @@ const NativeVideoCompressor = NativeModules.VideoCompressor;
6868const Video : VideoCompressorType = {
6969 compress : async (
7070 fileUrl : string ,
71- options ?: { bitrate ?: number ; compressionMethod ?: compressionMethod } ,
71+ options ?: {
72+ bitrate ?: number ;
73+ compressionMethod ?: compressionMethod ;
74+ maxSize ?: number ;
75+ } ,
7276 onProgress ?: ( progress : number ) => void
7377 ) => {
7478 const uuid = uuidv4 ( ) ;
@@ -88,10 +92,19 @@ const Video: VideoCompressorType = {
8892 uuid : string ;
8993 bitrate ?: number ;
9094 compressionMethod ?: compressionMethod ;
95+ maxSize ?: number ;
9196 } = { uuid } ;
9297 if ( options ?. bitrate ) modifiedOptions . bitrate = options ?. bitrate ;
93- if ( options ?. compressionMethod )
98+ if ( options ?. compressionMethod ) {
9499 modifiedOptions . compressionMethod = options ?. compressionMethod ;
100+ } else {
101+ modifiedOptions . compressionMethod = 'manual' ;
102+ }
103+ if ( options ?. maxSize ) {
104+ modifiedOptions . maxSize = options ?. maxSize ;
105+ } else {
106+ modifiedOptions . maxSize = 640 ;
107+ }
95108 const result = await NativeVideoCompressor . compress (
96109 fileUrl ,
97110 modifiedOptions
You can’t perform that action at this time.
0 commit comments