@takeoffmedia/react-native-penthera 0.2.52 → 0.2.53
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.
- package/android/src/main/java/com/takeoffmediareactnativepenthera/AssetQueueObserver.kt +23 -21
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt +9 -7
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/errors/ErrorsMapped.kt +4 -2
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@ package com.takeoffmediareactnativepenthera
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import com.penthera.common.Common
|
|
5
5
|
import com.penthera.virtuososdk.client.IAsset
|
|
6
|
-
import com.penthera.virtuososdk.client.IAssetManager
|
|
7
6
|
import com.penthera.virtuososdk.client.IIdentifier
|
|
8
7
|
import com.penthera.virtuososdk.client.Observers
|
|
9
8
|
import com.penthera.virtuososdk.client.Virtuoso
|
|
@@ -34,7 +33,7 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
34
33
|
val assetId = updateAsset.assetId
|
|
35
34
|
updateItem(aAsset, true)
|
|
36
35
|
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.DOWNLOAD_COMPLETE, assetId, "")
|
|
37
|
-
|
|
36
|
+
mOfflineVideo.assetId.remove(assetId)
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
override fun engineEncounteredErrorDownloadingAsset(aAsset: IIdentifier) {
|
|
@@ -62,7 +61,7 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
62
61
|
val assetId = updateAsset.assetId
|
|
63
62
|
|
|
64
63
|
// Progress is for catalog item
|
|
65
|
-
if (assetId.isNotEmpty() &&
|
|
64
|
+
if (assetId.isNotEmpty() && assetId in mOfflineVideo.assetId) {
|
|
66
65
|
//update our asset status
|
|
67
66
|
//mActivity.runOnUiThread{ updateItemStatus(updateAsset, forceUpdate) }
|
|
68
67
|
//mOfflineVideo { updateItemStatus(updateAsset, forceUpdate) }
|
|
@@ -74,11 +73,11 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
74
73
|
Log.e("MiModulo","<<<<<<<<<<updateItemStatus>>>>>>>>>>>>")
|
|
75
74
|
|
|
76
75
|
asset?.let{
|
|
77
|
-
if(
|
|
76
|
+
if(it.assetId in mOfflineVideo.assetId){
|
|
78
77
|
mOfflineVideo.asset = asset
|
|
79
78
|
|
|
80
79
|
var progress = (asset.fractionComplete * 100.0).toInt()
|
|
81
|
-
|
|
80
|
+
|
|
82
81
|
if (forceUpdate || progress != lastProgress) {
|
|
83
82
|
val assetStatus : String
|
|
84
83
|
val value: String
|
|
@@ -90,29 +89,30 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
90
89
|
assetStatus = "Downloading"
|
|
91
90
|
value = "downloading"
|
|
92
91
|
}
|
|
93
|
-
Common.AssetStatus.
|
|
94
|
-
assetStatus = "
|
|
95
|
-
value = ""
|
|
92
|
+
Common.AssetStatus.DOWNLOAD_COMPLETE -> {
|
|
93
|
+
assetStatus = "complete"
|
|
94
|
+
value = "complete"
|
|
96
95
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
// Max simultaneous downloaded assets across account: 10
|
|
97
|
+
Common.AssetStatus.DOWNLOAD_DENIED_ACCOUNT -> {
|
|
98
|
+
assetStatus = "Error"
|
|
99
|
+
value = PentheraErrors.DOWNLOAD_DENIED_MAX_DEVICE_DOWNLOADS
|
|
100
100
|
}
|
|
101
|
+
// Max simultaneous copies of an asset across account: 1
|
|
101
102
|
Common.AssetStatus.DOWNLOAD_DENIED_COPIES -> {
|
|
102
|
-
assetStatus = "
|
|
103
|
+
assetStatus = "Error"
|
|
103
104
|
value = PentheraErrors.DOWNLOAD_DENIED_COPIES
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Common.AssetStatus.DOWNLOAD_COMPLETE -> {
|
|
110
|
-
assetStatus = "complete"
|
|
111
|
-
value = "complete"
|
|
106
|
+
//Max simultaneous download-enabled devices per account: 5
|
|
107
|
+
Common.AssetStatus.DOWNLOAD_DENIED_ASSET -> {
|
|
108
|
+
assetStatus = "Error"
|
|
109
|
+
value = PentheraErrors.DOWNLOAD_DENIED_ASSET
|
|
112
110
|
}
|
|
111
|
+
|
|
112
|
+
|
|
113
113
|
else -> {
|
|
114
114
|
if(allowableStorageRemaining == 0L) {
|
|
115
|
-
assetStatus = "
|
|
115
|
+
assetStatus = "Error"
|
|
116
116
|
value = "Insufficient storage for download"
|
|
117
117
|
} else {
|
|
118
118
|
assetStatus = "Queued"
|
|
@@ -120,9 +120,11 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
val hasError = assetStatus
|
|
123
|
+
val hasError = assetStatus == "Error"
|
|
124
124
|
if(hasError){
|
|
125
125
|
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, it.assetId, value)
|
|
126
|
+
} else if(assetStatus == "Downloading") {
|
|
127
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.PROGRESS_UPDATED, it.assetId, progress.toString())
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
}
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt
CHANGED
|
@@ -42,7 +42,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
42
42
|
private lateinit var queueObserver: AssetQueueObserver
|
|
43
43
|
|
|
44
44
|
var asset: IAsset? = null
|
|
45
|
-
var assetId: String =
|
|
45
|
+
var assetId: MutableList<String> = mutableListOf()
|
|
46
46
|
private val gson = Gson()
|
|
47
47
|
|
|
48
48
|
private val enginePauseObserver: Observers.IEngineObserver = object : EngineObserver() {
|
|
@@ -106,8 +106,8 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
106
106
|
fun downloadAsset(newItem: String, activity: Activity) {
|
|
107
107
|
val data = JSONObject(newItem)
|
|
108
108
|
val item = data["item"] as JSONObject
|
|
109
|
+
assetId.add(item["id"].toString())
|
|
109
110
|
val url = data["url"].toString()
|
|
110
|
-
assetId = item["id"].toString()
|
|
111
111
|
val metadata = item.toString()
|
|
112
112
|
val fileList: MutableList<AncillaryFile> = ArrayList()
|
|
113
113
|
val static = item["static"] as JSONObject
|
|
@@ -147,7 +147,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
val params = MPDAssetBuilder().apply {
|
|
150
|
-
assetId(
|
|
150
|
+
assetId(item["id"].toString())
|
|
151
151
|
manifestUrl(URL(url))
|
|
152
152
|
assetObserver(AssetParseObserver(context))
|
|
153
153
|
addToQueue(true)
|
|
@@ -259,15 +259,17 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
259
259
|
val result = Arguments.createMap()
|
|
260
260
|
|
|
261
261
|
for (i in 0 until assetIds.size()) {
|
|
262
|
-
val
|
|
263
|
-
val asset = assetManager.getByAssetId(
|
|
262
|
+
val idValue = assetIds.getString(i)
|
|
263
|
+
val asset = assetManager.getByAssetId(idValue)
|
|
264
264
|
.firstOrNull() as? IAsset
|
|
265
265
|
|
|
266
266
|
if (asset != null) {
|
|
267
267
|
assetManager.delete(asset)
|
|
268
|
-
result.putBoolean(
|
|
268
|
+
result.putBoolean(idValue, true)
|
|
269
|
+
assetId.remove(idValue)
|
|
269
270
|
} else {
|
|
270
|
-
result.putBoolean(
|
|
271
|
+
result.putBoolean(idValue, false)
|
|
272
|
+
assetId.remove(idValue)
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
275
|
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/errors/ErrorsMapped.kt
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package com.takeoffmediareactnativepenthera.virtuoso.errors
|
|
2
2
|
|
|
3
3
|
object PentheraErrors {
|
|
4
|
-
const val DOWNLOAD_DENIED_ASSET = "The asset has already been downloaded as many times as permitted. To download this asset again, administrative action is required."
|
|
5
|
-
const val DOWNLOAD_DENIED_COPIES = "There are already as many downloaded copies of this asset as permitted on this account. To continue downloading, the user must delete a copy of this asset from one of their devices."
|
|
6
4
|
const val DOWNLOAD_DENIED_MAX_DEVICE_DOWNLOADS = "There are already as many downloads as permitted on this account. To continue downloading, the user must delete downloaded assets from one of their devices."
|
|
5
|
+
const val DOWNLOAD_DENIED_COPIES = "There are already as many downloaded copies of this asset as permitted on this account. To continue downloading, the user must delete a copy of this asset from one of their devices."
|
|
6
|
+
const val DOWNLOAD_DENIED_ASSET = "The asset has already been downloaded as many times as permitted. To download this asset again, administrative action is required."
|
|
7
|
+
|
|
8
|
+
|
|
7
9
|
}
|