@takeoffmedia/react-native-penthera 0.2.40 → 0.2.42

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.
@@ -6,12 +6,15 @@ import com.penthera.virtuososdk.client.IAsset
6
6
  import com.penthera.virtuososdk.client.IAssetManager
7
7
  import com.penthera.virtuososdk.client.IIdentifier
8
8
  import com.penthera.virtuososdk.client.Observers
9
+ import com.penthera.virtuososdk.client.Virtuoso
9
10
  import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
10
11
 
11
- class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine) : Observers.IQueueObserver {
12
+ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso) : Observers.IQueueObserver {
12
13
 
13
14
  private var lastProgress : Int = -1
14
15
  private var mOfflineVideo : OfflineVideoEngine = mOfflineVideo
16
+ private var istanceVirtuoso: Virtuoso = virtuoso
17
+
15
18
 
16
19
  override fun engineStartedDownloadingAsset(aAsset: IIdentifier) {
17
20
  val updateAsset = aAsset as IAsset
@@ -87,61 +90,36 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine) : Observers.IQueueO
87
90
 
88
91
  var progress = (asset.fractionComplete * 100.0).toInt()
89
92
  EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.PROGRESS_UPDATED, it.assetId, progress.toString())
90
- // Not a repeated progress -- Keep context switches minimal due to frequency of messages, unless forced
91
93
  if (forceUpdate || progress != lastProgress) {
92
94
  val assetStatus : String
93
95
  val value: String
94
96
  val status = asset.downloadStatus
97
+ val allowableStorageRemaining = istanceVirtuoso.allowableStorageRemaining
95
98
  when (status) {
96
-
97
99
  Common.AssetStatus.DOWNLOADING -> {
98
100
  assetStatus = "Downloading"
99
101
  value = "downloading"
100
102
  }
101
-
102
- Common.AssetStatus.DOWNLOAD_COMPLETE -> {
103
- assetStatus = "Downloading"
104
- value = "complete"
105
- }
106
-
107
- Common.AssetStatus.EXPIRED -> {
108
- assetStatus = "Expired"
109
- value = "expired"
110
- }
111
-
112
103
  Common.AssetStatus.DOWNLOAD_DENIED_ASSET -> {
113
104
  assetStatus = "Queued"
114
105
  value = "The asset has already been downloaded as many times as permitted. To download this asset again, administrative action is required."
115
106
  }
116
-
117
- Common.AssetStatus.DOWNLOAD_DENIED_ACCOUNT -> {
118
- assetStatus = "Queued"
119
- value = "DENIED : MDA"
120
- }
121
-
122
- Common.AssetStatus.DOWNLOAD_DENIED_EXTERNAL_POLICY -> {
123
- assetStatus = "Queued"
124
- value = "DENIED : EXT"
125
- }
126
-
127
107
  Common.AssetStatus.DOWNLOAD_DENIED_MAX_DEVICE_DOWNLOADS -> {
128
108
  assetStatus = "Queued"
129
- value = "DENIED :MPD Test maximo copias"
130
- }
131
-
132
- Common.AssetStatus.DOWNLOAD_BLOCKED_AWAITING_PERMISSION -> {
133
- assetStatus = "Queued"
134
- value = "AWAITING PERMISSION"
109
+ value = "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."
135
110
  }
136
-
137
111
  Common.AssetStatus.DOWNLOAD_DENIED_COPIES -> {
138
112
  assetStatus = "Queued"
139
113
  value = "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."
140
114
  }
141
-
142
115
  else -> {
143
- assetStatus = "Queued"
144
- value = "pending"
116
+ if(allowableStorageRemaining == 0L) {
117
+ assetStatus = "Queued"
118
+ value = "Insufficient storage for download"
119
+ } else {
120
+ assetStatus = "Queued"
121
+ value = "pending"
122
+ }
145
123
  }
146
124
  }
147
125
  if(assetStatus !== "Downloading"){
@@ -46,7 +46,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
46
46
 
47
47
  private fun getVirtuoso(activity: Activity): Virtuoso {
48
48
  virtuoso = Virtuoso(context)
49
- queueObserver = AssetQueueObserver(this)
49
+ queueObserver = AssetQueueObserver(this, virtuoso)
50
50
  onResume()
51
51
  return virtuoso
52
52
  }
@@ -126,6 +126,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
126
126
  val columnNames = cursor?.columnNames
127
127
 
128
128
  while (cursor?.moveToNext() == true && columnNames != null) {
129
+ val assetManager = virtuoso.assetManager
129
130
  val dataMap = mutableMapOf<String, Any>()
130
131
  for (columnName in columnNames) {
131
132
  val columnIndex = cursor.getColumnIndex(columnName)
@@ -144,10 +145,14 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
144
145
  dataMap["id"] = value
145
146
  }
146
147
  if (columnName == "durationSeconds") {
147
- dataMap["duration"] = value
148
+ dataMap["data"] = (dataMap["data"] as? MutableMap<String, Any> ?: mutableMapOf()).apply {
149
+ put("duration", value)
150
+ }
148
151
  }
149
152
  if (columnName == "expectedSize") {
150
- dataMap["estimatedSize"] = value
153
+ dataMap["data"] = (dataMap["data"] as? MutableMap<String, Any> ?: mutableMapOf()).apply {
154
+ put("estimatedSize", value)
155
+ }
151
156
  }
152
157
  }
153
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeoffmedia/react-native-penthera",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -166,4 +166,4 @@
166
166
  "dependencies": {
167
167
  "zustand": "^4.4.0"
168
168
  }
169
- }
169
+ }