@@ -40,7 +40,7 @@ public class FlutterVESDK: FlutterIMGLY, FlutterPlugin, VideoEditViewControllerD
40
40
guard let arguments = call. arguments as? IMGLYDictionary else { return }
41
41
42
42
if self . result != nil {
43
- result ( FlutterError ( code: " Multiple requests. " , message: " Cancelled due to multiple requests. " , details: nil ) )
43
+ result ( FlutterError ( code: IMGLYConstants . kErrorMultipleRequests , message: " Cancelled due to multiple requests. " , details: nil ) )
44
44
return
45
45
}
46
46
@@ -84,15 +84,15 @@ public class FlutterVESDK: FlutterIMGLY, FlutterPlugin, VideoEditViewControllerD
84
84
if valid == true {
85
85
video = Video ( segments: assets)
86
86
} else {
87
- result ( FlutterError ( code: " Invalid video size: width and height must be greater than zero. " , message : nil , details: nil ) )
87
+ result ( FlutterError ( code: IMGLYConstants . kErrorUnableToLoad , message : " Invalid video size: width and height must be greater than zero. " , details: nil ) )
88
88
return
89
89
}
90
90
}
91
91
} else {
92
92
if let videoSize = size {
93
93
video = Video ( size: videoSize)
94
94
} else {
95
- result ( FlutterError ( code: " A video composition without assets must have a specific size. " , message : nil , details: nil ) )
95
+ result ( FlutterError ( code: IMGLYConstants . kErrorUnableToLoad , message : " A video composition without assets must have a specific size. " , details: nil ) )
96
96
return
97
97
}
98
98
}
@@ -113,15 +113,15 @@ public class FlutterVESDK: FlutterIMGLY, FlutterPlugin, VideoEditViewControllerD
113
113
if valid == true {
114
114
video = Video ( segments: resolvedSegments)
115
115
} else {
116
- result ( FlutterError ( code: " Invalid video size: width and height must be greater than zero. " , message : nil , details: nil ) )
116
+ result ( FlutterError ( code: IMGLYConstants . kErrorUnableToLoad , message : " Invalid video size: width and height must be greater than zero. " , details: nil ) )
117
117
return
118
118
}
119
119
}
120
120
} else {
121
121
if let videoSize = size {
122
122
video = Video ( size: videoSize)
123
123
} else {
124
- result ( FlutterError ( code: " A video composition without assets must have a specific size. " , message : nil , details: nil ) )
124
+ result ( FlutterError ( code: IMGLYConstants . kErrorUnableToLoad , message : " A video composition without assets must have a specific size. " , details: nil ) )
125
125
return
126
126
}
127
127
}
@@ -134,13 +134,13 @@ public class FlutterVESDK: FlutterIMGLY, FlutterPlugin, VideoEditViewControllerD
134
134
video = Video ( size: videoSize)
135
135
}
136
136
guard let finalVideo = video else {
137
- result ( FlutterError ( code: " Could not load video. " , message : nil , details: nil ) )
137
+ result ( FlutterError ( code: IMGLYConstants . kErrorUnableToLoad , message : " Could not load video. " , details: nil ) )
138
138
return
139
139
}
140
140
141
141
self . present ( video: finalVideo, configuration: configuration, serialization: serialization)
142
142
} else {
143
- result ( FlutterError ( code: " The video must not be null. " , message : nil , details: nil ) )
143
+ result ( FlutterError ( code: IMGLYConstants . kErrorUnableToLoad , message : " The video must not be null. " , details: nil ) )
144
144
return
145
145
}
146
146
}
@@ -185,9 +185,11 @@ public class FlutterVESDK: FlutterIMGLY, FlutterPlugin, VideoEditViewControllerD
185
185
DispatchQueue . main. async {
186
186
do {
187
187
try VESDK . unlockWithLicense ( from: url)
188
+ self . result ? ( nil )
188
189
self . result = nil
189
190
} catch let error {
190
- self . handleLicenseError ( with: error as NSError )
191
+ self . result ? ( FlutterError ( code: IMGLYConstants . kErrorUnableToUnlock, message: " Unlocking the SDK failed due to: " , details: error. localizedDescription) )
192
+ self . result = nil
191
193
}
192
194
}
193
195
}
@@ -253,26 +255,26 @@ extension FlutterVESDK {
253
255
254
256
if self . serializationEnabled == true {
255
257
guard let serializationData = videoEditViewController. serializedSettings else {
256
- self . handleError ( videoEditViewController, code: " Serialization failed. " , message: " No serialization data found. " , details: nil )
258
+ self . handleError ( videoEditViewController, code: IMGLYConstants . kErrorUnableToExport , message: " No serialization data found. " , details: nil )
257
259
return
258
260
}
259
261
if self . serializationType == IMGLYConstants . kExportTypeFileURL {
260
262
guard let exportURL = self . serializationFile else {
261
- self . handleError ( videoEditViewController, code: " Serialization failed. " , message: " The URL must not be nil. " , details: nil )
263
+ self . handleError ( videoEditViewController, code: IMGLYConstants . kErrorUnableToExport , message: " The URL must not be nil. " , details: nil )
262
264
return
263
265
}
264
266
do {
265
267
try serializationData. IMGLYwriteToUrl ( exportURL, andCreateDirectoryIfNeeded: true )
266
268
serialization = self . serializationFile? . absoluteString
267
269
} catch let error {
268
- self . handleError ( videoEditViewController, code: " Serialization failed. " , message: error. localizedDescription, details: error. localizedDescription)
270
+ self . handleError ( videoEditViewController, code: IMGLYConstants . kErrorUnableToExport , message: error. localizedDescription, details: error. localizedDescription)
269
271
return
270
272
}
271
273
} else if self . serializationType == IMGLYConstants . kExportTypeObject {
272
274
do {
273
275
serialization = try JSONSerialization . jsonObject ( with: serializationData, options: . init( rawValue: 0 ) )
274
276
} catch let error {
275
- self . handleError ( videoEditViewController, code: " Serialization failed. " , message: error. localizedDescription, details: error. localizedDescription)
277
+ self . handleError ( videoEditViewController, code: IMGLYConstants . kErrorUnableToExport , message: error. localizedDescription, details: error. localizedDescription)
276
278
return
277
279
}
278
280
}
@@ -294,7 +296,7 @@ extension FlutterVESDK {
294
296
/// - Parameter videoEditViewController: The `VideoEditViewController` that failed to export the video.
295
297
/// - Parameter error: The `VideoEditorError` that caused the failure.
296
298
public func videoEditViewControllerDidFail( _ videoEditViewController: VideoEditViewController , error: VideoEditorError ) {
297
- self . handleError ( videoEditViewController, code: " Editor failed " , message: " The editor did fail to generate the video. " , details: error. localizedDescription)
299
+ self . handleError ( videoEditViewController, code: IMGLYConstants . kErrorUnableToExport , message: " The editor did fail to generate the video. " , details: error. localizedDescription)
298
300
}
299
301
300
302
/// Called if the `VideoEditViewController` was cancelled.
0 commit comments