@takeoffmedia/react-native-penthera 0.6.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -259,9 +259,46 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
259
259
 
260
260
  @SuppressLint("ShowToast")
261
261
  override fun complete(asset: ISegmentedAsset?, error: Int, addedToQueue: Boolean) {
262
+ if (!addedToQueue) {
263
+ if (asset == null) {
264
+ EventEmitter.sharedInstance.dispatch(
265
+ "penthera",
266
+ PentheraEvent.ERROR_DOWNLOAD,
267
+ "unknown_mediaId",
268
+ "Asset is null"
269
+ )
270
+ return
271
+ }
272
+ val body: String
273
+ val status = asset.downloadStatus
274
+ body = when (status) {
275
+ // Max simultaneous downloaded assets across account: 10
276
+ Common.AssetStatus.DOWNLOAD_DENIED_ACCOUNT -> {
277
+ PentheraErrors.DOWNLOAD_DENIED_MAX_DEVICE_DOWNLOADS
278
+ }
279
+ // Max simultaneous copies of an asset across account: 1
280
+ Common.AssetStatus.DOWNLOAD_DENIED_COPIES -> {
281
+ PentheraErrors.DOWNLOAD_DENIED_COPIES
282
+ }
283
+ // Max simultaneous download-enabled devices per account: 5
284
+ Common.AssetStatus.DOWNLOAD_DENIED_ASSET -> {
285
+ PentheraErrors.DOWNLOAD_DENIED_ASSET
286
+ }
287
+ else -> {
288
+ error.toString()
289
+ }
290
+ }
291
+ val metadata = JSONObject((asset as VirtuosoSegmentedFile).metadata)
292
+ val mediaId = if (metadata.has("mediaId")) metadata["mediaId"] as String else asset.assetId
293
+ EventEmitter.sharedInstance.dispatch(
294
+ "penthera",
295
+ PentheraEvent.ERROR_DOWNLOAD,
296
+ mediaId,
297
+ body
298
+ )
299
+ }
262
300
  }
263
- }
264
-
301
+ }
265
302
  fun deleteMany(assetIds: ReadableArray, promise: Promise) {
266
303
  val assetManager = virtuoso.assetManager
267
304
  val result = Arguments.createMap()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeoffmedia/react-native-penthera",
3
- "version": "0.6.3",
3
+ "version": "0.8.0",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",