@takeoffmedia/react-native-penthera 0.3.7 → 0.4.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.
- package/android/src/main/java/com/takeoffmediareactnativepenthera/AssetQueueObserver.kt +12 -5
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt +24 -14
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/notification/NotificationFactory.kt +6 -3
- package/ios/Catalog.swift +11 -1
- package/ios/Penthera.swift +92 -19
- package/ios/Penthera.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Penthera.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Penthera.xcodeproj/project.xcworkspace/xcuserdata/joseguerreroot.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +104 -0
- package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/hooks/usePenthera/usePenthera.js +38 -17
- package/lib/commonjs/hooks/usePenthera/usePenthera.js.map +1 -1
- package/lib/commonjs/hooks/usePenthera/usePentheraInit.js +1 -0
- package/lib/commonjs/hooks/usePenthera/usePentheraInit.js.map +1 -1
- package/lib/module/hooks/usePenthera/usePenthera.js +38 -17
- package/lib/module/hooks/usePenthera/usePenthera.js.map +1 -1
- package/lib/module/hooks/usePenthera/usePentheraInit.js +1 -0
- package/lib/module/hooks/usePenthera/usePentheraInit.js.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePenthera.d.ts.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePenthera.types.d.ts +11 -1
- package/lib/typescript/hooks/usePenthera/usePenthera.types.d.ts.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePentheraInit.d.ts.map +1 -1
- package/lib/typescript/interface/PentheraTypes.d.ts +3 -1
- package/lib/typescript/interface/PentheraTypes.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/usePenthera/usePenthera.tsx +152 -126
- package/src/hooks/usePenthera/usePenthera.types.ts +12 -1
- package/src/hooks/usePenthera/usePentheraInit.tsx +6 -7
- package/src/interface/PentheraTypes.ts +3 -1
|
@@ -9,6 +9,7 @@ import com.penthera.virtuososdk.client.Observers
|
|
|
9
9
|
import com.penthera.virtuososdk.client.Virtuoso
|
|
10
10
|
import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
|
|
11
11
|
import com.takeoffmediareactnativepenthera.virtuoso.errors.PentheraErrors
|
|
12
|
+
import org.json.JSONObject
|
|
12
13
|
|
|
13
14
|
class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso) : Observers.IQueueObserver {
|
|
14
15
|
|
|
@@ -29,7 +30,9 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
29
30
|
updateItem(aAsset, true)
|
|
30
31
|
val eventCategory = "penthera"
|
|
31
32
|
val eventType = PentheraEvent.DID_START_DOWNLOADING
|
|
32
|
-
|
|
33
|
+
val metadata = JSONObject(aAsset.metadata)
|
|
34
|
+
val mediaId = metadata["mediaId"] as String
|
|
35
|
+
EventEmitter.sharedInstance.dispatch(eventCategory, eventType, mediaId, "")
|
|
33
36
|
} catch (e: Exception) {
|
|
34
37
|
// Handle the exception here, for example, log it
|
|
35
38
|
Log.e("MiModulo", "Error in engineStartedDownloadingAsset", e)
|
|
@@ -52,7 +55,9 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
52
55
|
updateItem(aAsset, true)
|
|
53
56
|
val eventCategory = "penthera"
|
|
54
57
|
val eventType = PentheraEvent.DOWNLOAD_COMPLETE
|
|
55
|
-
|
|
58
|
+
val metadata = JSONObject(aAsset.metadata)
|
|
59
|
+
val mediaId = metadata["mediaId"] as String
|
|
60
|
+
EventEmitter.sharedInstance.dispatch(eventCategory, eventType, mediaId, "")
|
|
56
61
|
mOfflineVideo.assetId.remove(assetId)
|
|
57
62
|
} catch (e: Exception) {
|
|
58
63
|
// Handle the exception here, for example, log it
|
|
@@ -151,16 +156,18 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
val hasError = assetStatus == "Error"
|
|
159
|
+
val metadata = JSONObject(it.metadata)
|
|
160
|
+
val mediaId = metadata["mediaId"] as String
|
|
154
161
|
if(hasError){
|
|
155
|
-
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD,
|
|
162
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, mediaId, value)
|
|
156
163
|
} else if(assetStatus == "Downloading") {
|
|
157
164
|
val speedInMbs = mOfflineVideo.mService.windowedThroughput
|
|
158
165
|
runOnUiThread {
|
|
159
166
|
if(speedInMbs <= mOfflineVideo.minimumLowBandWidth && progress > 1){
|
|
160
|
-
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD,
|
|
167
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, mediaId, PentheraErrors.LOW_BAND_WIDTH)
|
|
161
168
|
}
|
|
162
169
|
}
|
|
163
|
-
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.PROGRESS_UPDATED,
|
|
170
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.PROGRESS_UPDATED, mediaId, progress.toString())
|
|
164
171
|
}
|
|
165
172
|
}
|
|
166
173
|
}
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt
CHANGED
|
@@ -180,6 +180,9 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
180
180
|
val value = cursor.getString(columnIndex)
|
|
181
181
|
if (columnName == "description") {
|
|
182
182
|
val jsonObject = Gson().fromJson(value, Map::class.java)
|
|
183
|
+
val asset = JSONObject(value)
|
|
184
|
+
val metadata = asset.getJSONObject("data")
|
|
185
|
+
dataMap["id"] = metadata["mediaId"]
|
|
183
186
|
dataMap["data"] = jsonObject["data"] as Any
|
|
184
187
|
dataMap["title"] = jsonObject["title"] as Any
|
|
185
188
|
dataMap["thumbnails"] = jsonObject["thumbnails"] as Any
|
|
@@ -187,21 +190,10 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
187
190
|
dataMap[columnName] = value
|
|
188
191
|
}
|
|
189
192
|
if (columnName == "assetId") {
|
|
190
|
-
dataMap["id"] = value
|
|
191
193
|
UiThreadUtil.runOnUiThread {
|
|
192
194
|
val list = virtuoso.assetManager.getByAssetId(value)
|
|
193
|
-
list.let {
|
|
194
|
-
|
|
195
|
-
asset = list[0] as VirtuosoSegmentedFile
|
|
196
|
-
if (asset?.downloadStatus == Common.AssetStatus.DOWNLOAD_DENIED_COPIES) {
|
|
197
|
-
EventEmitter.sharedInstance.dispatch(
|
|
198
|
-
"penthera",
|
|
199
|
-
PentheraEvent.ERROR_DOWNLOAD,
|
|
200
|
-
value,
|
|
201
|
-
PentheraErrors.DOWNLOAD_DENIED_COPIES
|
|
202
|
-
)
|
|
203
|
-
}
|
|
204
|
-
}
|
|
195
|
+
list.firstOrNull()?.let { asset ->
|
|
196
|
+
processAsset(asset as VirtuosoSegmentedFile)
|
|
205
197
|
}
|
|
206
198
|
}
|
|
207
199
|
}
|
|
@@ -230,7 +222,8 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
230
222
|
val eadFormated = dateToString(ead)
|
|
231
223
|
val eapFormated = dateToString(eap)
|
|
232
224
|
(dataMap["data"] as? MutableMap<String, Any> ?: mutableMapOf()).apply {
|
|
233
|
-
put("effectiveExpiryDate", if (value == "0") eadFormated else eapFormated)
|
|
225
|
+
put("effectiveExpiryDate", if (value == "0") eadFormated else eapFormated);
|
|
226
|
+
put("isReproduced", value != "0");
|
|
234
227
|
}.also { dataMap["data"] = it }
|
|
235
228
|
}
|
|
236
229
|
}
|
|
@@ -243,6 +236,23 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
243
236
|
promise.resolve(gson.toJson(completedList))
|
|
244
237
|
}
|
|
245
238
|
|
|
239
|
+
private fun processAsset(asset: VirtuosoSegmentedFile) {
|
|
240
|
+
when (asset.downloadStatus) {
|
|
241
|
+
Common.AssetStatus.DOWNLOAD_DENIED_COPIES -> {
|
|
242
|
+
val metadata = JSONObject((asset as VirtuosoSegmentedFile).metadata)
|
|
243
|
+
EventEmitter.sharedInstance.dispatch(
|
|
244
|
+
"penthera",
|
|
245
|
+
PentheraEvent.ERROR_DOWNLOAD,
|
|
246
|
+
metadata["mediaId"] as String,
|
|
247
|
+
PentheraErrors.DOWNLOAD_DENIED_COPIES
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
Common.AssetStatus.EXPIRED -> {
|
|
251
|
+
virtuoso.assetManager.delete(asset)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
246
256
|
private fun dateToString(seconds: String): String {
|
|
247
257
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
|
248
258
|
return try {
|
|
@@ -31,6 +31,7 @@ class NotificationFactory(private val applicationName: String) {
|
|
|
31
31
|
private val TAG = NotificationFactory::class.java.simpleName
|
|
32
32
|
private var notificationChannel : NotificationChannel? = null
|
|
33
33
|
private var compatNotificationBuilder: NotificationCompat.Builder? = null
|
|
34
|
+
private val TAG_DEV = "DEVELOPMENT TAKEOFF"
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
|
|
@@ -199,11 +200,13 @@ class NotificationFactory(private val applicationName: String) {
|
|
|
199
200
|
title += asset?.metadata + " complete."
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
STOPPED_NOTIFICATION -> title += "stopped downloads."
|
|
203
|
+
//STOPPED_NOTIFICATION -> title += "stopped downloads."
|
|
204
|
+
STOPPED_NOTIFICATION -> Log.d(TAG_DEV, "STOPPED_NOTIFICATION")
|
|
203
205
|
|
|
204
206
|
PAUSED_NOTIFICATION -> title += "paused downloads."
|
|
205
207
|
|
|
206
|
-
RESTART_NOTIFICATION -> title += "is starting up..."
|
|
208
|
+
//RESTART_NOTIFICATION -> title += "is starting up..."
|
|
209
|
+
RESTART_NOTIFICATION -> Log.d(TAG_DEV, "RESTART_NOTIFICATION")
|
|
207
210
|
|
|
208
211
|
FAILED_NOTIFICATION -> title += " asset could not be queued"
|
|
209
212
|
}
|
|
@@ -279,4 +282,4 @@ class NotificationFactory(private val applicationName: String) {
|
|
|
279
282
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_FROM_BACKGROUND
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
|
-
}
|
|
285
|
+
}
|
package/ios/Catalog.swift
CHANGED
|
@@ -61,7 +61,9 @@ struct DataItem: Codable {
|
|
|
61
61
|
var isExpired: Bool?
|
|
62
62
|
var inForcedExpire: Bool?
|
|
63
63
|
var effectiveExpiryDate: String?
|
|
64
|
-
|
|
64
|
+
var isReproduced: Bool?
|
|
65
|
+
var mediaId: String?
|
|
66
|
+
var vpid: String?
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
struct Offers: Codable {
|
|
@@ -143,4 +145,12 @@ struct AssetData: Codable {
|
|
|
143
145
|
let js: String?
|
|
144
146
|
let css: String?
|
|
145
147
|
let hasZoom: Bool?
|
|
148
|
+
let infoVideoPlayer: VideoPlayerInfo?
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
struct VideoPlayerInfo: Codable {
|
|
152
|
+
var title: String?
|
|
153
|
+
var description: String?
|
|
154
|
+
var advisoryClassification: String?
|
|
155
|
+
var advisoryDescription: String?
|
|
146
156
|
}
|
package/ios/Penthera.swift
CHANGED
|
@@ -18,7 +18,6 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
18
18
|
var maxStorageAllowed: Int64 = 20 * 1024 * 1024 // 20 GB = 20480 MB
|
|
19
19
|
var minimumLowBandWidth: Double = 500 // 500 kbps
|
|
20
20
|
var assetError: String = ""
|
|
21
|
-
|
|
22
21
|
var vcHttpServer: VirtuosoClientHTTPServer? = nil
|
|
23
22
|
|
|
24
23
|
func updateStatusInfo() {
|
|
@@ -36,11 +35,21 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
36
35
|
let assetId = self.currentAset?.assetID
|
|
37
36
|
// allowableStorageRemaining Returns the amount of device storage (in bytes) still available for Virtuoso to use
|
|
38
37
|
if(allowableStorageRemaining <= 0){
|
|
39
|
-
EventEmitter.sharedInstance.dispatch(
|
|
38
|
+
EventEmitter.sharedInstance.dispatch(
|
|
39
|
+
name: "penthera",
|
|
40
|
+
code: PentheraEvent.ERROR_DOWNLOAD,
|
|
41
|
+
assetId: self.currentAset?.userInfo?["mediaId"] as! String,
|
|
42
|
+
body: "Insufficient storage for download"
|
|
43
|
+
)
|
|
40
44
|
//This condition starts with the interval of 30 since we can have an estimate of kbps per second from approximately 20
|
|
41
45
|
} else if kbpsInt > 0 {
|
|
42
46
|
if kbpsInt <= self.minimumLowBandWidth {
|
|
43
|
-
EventEmitter.sharedInstance.dispatch(
|
|
47
|
+
EventEmitter.sharedInstance.dispatch(
|
|
48
|
+
name: "penthera",
|
|
49
|
+
code: PentheraEvent.ERROR_DOWNLOAD,
|
|
50
|
+
assetId: self.currentAset?.userInfo?["mediaId"] as! String,
|
|
51
|
+
body: "Low bandwidth or no connection"
|
|
52
|
+
)
|
|
44
53
|
// self.currentAset?.delete()
|
|
45
54
|
}
|
|
46
55
|
}
|
|
@@ -157,7 +166,12 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
157
166
|
self.currentAset = asset
|
|
158
167
|
self.assetError = ""
|
|
159
168
|
updateStatusInfo()
|
|
160
|
-
EventEmitter.sharedInstance.dispatch(
|
|
169
|
+
EventEmitter.sharedInstance.dispatch(
|
|
170
|
+
name: "penthera",
|
|
171
|
+
code: PentheraEvent.DID_START_DOWNLOADING,
|
|
172
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
173
|
+
body: ""
|
|
174
|
+
)
|
|
161
175
|
}
|
|
162
176
|
|
|
163
177
|
|
|
@@ -166,7 +180,12 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
166
180
|
updateStatusInfo()
|
|
167
181
|
let percentage: Float = Float(asset.fractionComplete)/Float(asset.estimatedSize)
|
|
168
182
|
if(percentage.isFinite && self.assetError.isEmpty ) {
|
|
169
|
-
EventEmitter.sharedInstance.dispatch(name: "penthera",
|
|
183
|
+
EventEmitter.sharedInstance.dispatch(name: "penthera",
|
|
184
|
+
code: PentheraEvent.PROGRESS_UPDATED,
|
|
185
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
186
|
+
body: "\(Int(asset.fractionComplete*100))"
|
|
187
|
+
)
|
|
188
|
+
|
|
170
189
|
}
|
|
171
190
|
}
|
|
172
191
|
|
|
@@ -176,7 +195,12 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
176
195
|
|
|
177
196
|
public func downloadEngineDidFinishDownloadingAsset(_ asset: VirtuosoAsset) {
|
|
178
197
|
updateStatusInfo()
|
|
179
|
-
EventEmitter.sharedInstance.dispatch(
|
|
198
|
+
EventEmitter.sharedInstance.dispatch(
|
|
199
|
+
name: "penthera",
|
|
200
|
+
code: PentheraEvent.DOWNLOAD_COMPLETE,
|
|
201
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
202
|
+
body: ""
|
|
203
|
+
)
|
|
180
204
|
}
|
|
181
205
|
|
|
182
206
|
func downloadEngineStatusChange(_ status: kVDE_DownloadEngineStatus) {
|
|
@@ -186,15 +210,30 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
186
210
|
public func downloadEngineDidEncounterError(for asset: VirtuosoAsset, error: Error?, task: URLSessionTask?, data: Data?, statusCode: NSNumber?) {
|
|
187
211
|
let eventError = parseErrorRulesPenthera(anyElement: error);
|
|
188
212
|
self.assetError = eventError
|
|
189
|
-
EventEmitter.sharedInstance.dispatch(
|
|
213
|
+
EventEmitter.sharedInstance.dispatch(
|
|
214
|
+
name: "penthera",
|
|
215
|
+
code: PentheraEvent.ERROR_DOWNLOAD,
|
|
216
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
217
|
+
body: eventError
|
|
218
|
+
)
|
|
190
219
|
}
|
|
191
220
|
|
|
192
221
|
public func downloadEngineInternalQueueUpdate(asset: VirtuosoAsset) {
|
|
193
|
-
EventEmitter.sharedInstance.dispatch(
|
|
222
|
+
EventEmitter.sharedInstance.dispatch(
|
|
223
|
+
name: "penthera",
|
|
224
|
+
code: "TEST downloadEngineInternalQueueUpdate",
|
|
225
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
226
|
+
body: "Queue updated"
|
|
227
|
+
)
|
|
194
228
|
}
|
|
195
229
|
|
|
196
230
|
public func downloadEngineStartupComplete(_ succeeded: Bool, asset: VirtuosoAsset) {
|
|
197
|
-
EventEmitter.sharedInstance.dispatch(
|
|
231
|
+
EventEmitter.sharedInstance.dispatch(
|
|
232
|
+
name: "penthera",
|
|
233
|
+
code: "TEST downloadEngineStartupComplete",
|
|
234
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
235
|
+
body: "SDK startup complete"
|
|
236
|
+
)
|
|
198
237
|
}
|
|
199
238
|
func getPendingAsset(assetID: String) -> VirtuosoAsset? {
|
|
200
239
|
let pendingAssets = VirtuosoAsset.pendingAssets(withAvailabilityFilter: false)
|
|
@@ -257,15 +296,26 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
257
296
|
|
|
258
297
|
let hasDRM = item["drm"] as! Bool? ?? false
|
|
259
298
|
let title = item["title"] as! String? ?? ""
|
|
299
|
+
guard let metadata = item["data"] as! [String: AnyObject]? else {
|
|
300
|
+
reject("No metadata", nil, nil)
|
|
301
|
+
return
|
|
302
|
+
}
|
|
260
303
|
|
|
261
304
|
DispatchQueue.global(qos: .background).async {
|
|
262
305
|
guard let config = VirtuosoAssetConfig(url: url,
|
|
263
306
|
assetID: assetID,
|
|
264
307
|
description: String(describing: title),
|
|
265
|
-
type: .vde_AssetTypeHLS)
|
|
266
|
-
|
|
308
|
+
type: .vde_AssetTypeHLS)
|
|
309
|
+
else {
|
|
310
|
+
EventEmitter.sharedInstance.dispatch(
|
|
311
|
+
name: "penthera",
|
|
312
|
+
code: PentheraEvent.CONFIG_ASSET_FAILED,
|
|
313
|
+
assetId: metadata["mediaId"] as! String,
|
|
314
|
+
body: "-"
|
|
315
|
+
)
|
|
267
316
|
return
|
|
268
317
|
}
|
|
318
|
+
|
|
269
319
|
// Ancillary Files
|
|
270
320
|
var ancillarySubtitles: [String: String] = [:]
|
|
271
321
|
let thumbnails = item["thumbnails"] as! [String: String]? ?? [:]
|
|
@@ -305,7 +355,12 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
305
355
|
FairPlayDrmSetup.initDrmUrls(certificateUrl: cert, licenceUrl: licence)
|
|
306
356
|
|
|
307
357
|
if (!FairPlayDrmSetup.configureAsset(assetID: assetID, header:licenceHttpHeader, token: token)) {
|
|
308
|
-
EventEmitter.sharedInstance.dispatch(
|
|
358
|
+
EventEmitter.sharedInstance.dispatch(
|
|
359
|
+
name: "penthera",
|
|
360
|
+
code: PentheraEvent.FAIR_PLAY_LICENSE_DELEGATE_ERROR,
|
|
361
|
+
assetId: metadata["mediaId"] as! String,
|
|
362
|
+
body: ""
|
|
363
|
+
)
|
|
309
364
|
return
|
|
310
365
|
}
|
|
311
366
|
|
|
@@ -354,8 +409,9 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
354
409
|
show: show?.fileDownloadURL ?? ""
|
|
355
410
|
)
|
|
356
411
|
|
|
357
|
-
let expiryDate = va.expiryDate
|
|
358
|
-
let effectiveExpiryDate = va.effectiveExpiryDate
|
|
412
|
+
let expiryDate = va.expiryDate
|
|
413
|
+
let effectiveExpiryDate = va.effectiveExpiryDate
|
|
414
|
+
let isReproduced = va.firstPlayDateTime
|
|
359
415
|
|
|
360
416
|
var dataItem = DataItem(
|
|
361
417
|
title: va.userInfo?["title"] as? String,
|
|
@@ -367,7 +423,10 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
367
423
|
expiryAfterPlay: timeIntervalToString(va.expiryAfterPlay),
|
|
368
424
|
expiryAfterDownload: timeIntervalToString(va.expiryAfterDownload),
|
|
369
425
|
isExpired: va.isExpired,
|
|
370
|
-
inForcedExpire:
|
|
426
|
+
inForcedExpire: va.inForcedExpire,
|
|
427
|
+
isReproduced: isReproduced != nil,
|
|
428
|
+
mediaId: va.userInfo?["mediaId"] as? String,
|
|
429
|
+
vpid: va.userInfo?["vpid"] as? String
|
|
371
430
|
)
|
|
372
431
|
|
|
373
432
|
if let effectiveExpiryDate = effectiveExpiryDate {
|
|
@@ -382,7 +441,7 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
382
441
|
va.delete()
|
|
383
442
|
} else {
|
|
384
443
|
let catalog = OfflineCatalog(
|
|
385
|
-
id: va.
|
|
444
|
+
id: va.userInfo?["mediaId"] as! String, // Change vpid to assetId
|
|
386
445
|
title: va.description,
|
|
387
446
|
data: dataItem,
|
|
388
447
|
thumbnails: thumbnails,
|
|
@@ -469,6 +528,7 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
469
528
|
|
|
470
529
|
let decoder = JSONEncoder()
|
|
471
530
|
var hasZoom: Bool? = false
|
|
531
|
+
var infoVideoPlayer: VideoPlayerInfo?
|
|
472
532
|
do {
|
|
473
533
|
|
|
474
534
|
vcHttpServer?.startup()
|
|
@@ -507,6 +567,14 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
507
567
|
if let hasZoomUI = userInfo["hasZoom"] as? Bool {
|
|
508
568
|
hasZoom = hasZoomUI
|
|
509
569
|
}
|
|
570
|
+
if let infoVideoPlayerDict = userInfo["infoVideoPlayer"] as? [String: Any] {
|
|
571
|
+
infoVideoPlayer = VideoPlayerInfo(
|
|
572
|
+
title: infoVideoPlayerDict["title"] as? String ?? "",
|
|
573
|
+
description: infoVideoPlayerDict["description"] as? String ?? "",
|
|
574
|
+
advisoryClassification: infoVideoPlayerDict["advisoryClassification"] as? String ?? "",
|
|
575
|
+
advisoryDescription: infoVideoPlayerDict["advisoryDescription"] as? String ?? ""
|
|
576
|
+
)
|
|
577
|
+
}
|
|
510
578
|
}
|
|
511
579
|
|
|
512
580
|
|
|
@@ -518,7 +586,8 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
518
586
|
subtitles: subtitlesResponse,
|
|
519
587
|
js: vcHttpServer?.ancillaryURLForAncillary(withTag: "js", usingMime: "js"),
|
|
520
588
|
css: vcHttpServer?.ancillaryURLForAncillary(withTag: "css", usingMime: "css"),
|
|
521
|
-
hasZoom: hasZoom
|
|
589
|
+
hasZoom: hasZoom,
|
|
590
|
+
infoVideoPlayer: infoVideoPlayer
|
|
522
591
|
)
|
|
523
592
|
|
|
524
593
|
|
|
@@ -544,14 +613,18 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
544
613
|
|
|
545
614
|
func pauseAsset(asset: VirtuosoAsset) {
|
|
546
615
|
asset.isPaused = !asset.isPaused
|
|
547
|
-
EventEmitter.sharedInstance.dispatch(
|
|
616
|
+
EventEmitter.sharedInstance.dispatch(
|
|
617
|
+
name: "penthera",
|
|
618
|
+
code: PentheraEvent.ASSET_RESUME_DOWNLOAD_UPDATED,
|
|
619
|
+
assetId: asset.userInfo?["mediaId"] as! String,
|
|
620
|
+
body: "\(asset.isPaused)"
|
|
621
|
+
)
|
|
548
622
|
}
|
|
549
623
|
|
|
550
624
|
@objc(shutdownDRM:withResolver:withRejecter:)
|
|
551
625
|
func shutdownDRM(_ blank: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
552
626
|
if let server = self.vcHttpServer {
|
|
553
627
|
server.shutdown()
|
|
554
|
-
|
|
555
628
|
resolve("Shutdown successful")
|
|
556
629
|
} else {
|
|
557
630
|
reject("NO_INSTANCE", "No instance for vcHttpServer", nil)
|
|
Binary file
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Bucket
|
|
3
|
+
uuid = "3AE98629-7421-4561-B12C-C06B8B6A3023"
|
|
4
|
+
type = "1"
|
|
5
|
+
version = "2.0">
|
|
6
|
+
<Breakpoints>
|
|
7
|
+
<BreakpointProxy
|
|
8
|
+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
9
|
+
<BreakpointContent
|
|
10
|
+
uuid = "A5D166B0-3C57-4F4D-A845-BDB81498DA0F"
|
|
11
|
+
shouldBeEnabled = "No"
|
|
12
|
+
ignoreCount = "0"
|
|
13
|
+
continueAfterRunningActions = "No"
|
|
14
|
+
filePath = "Penthera.swift"
|
|
15
|
+
startingColumnNumber = "9223372036854775807"
|
|
16
|
+
endingColumnNumber = "9223372036854775807"
|
|
17
|
+
startingLineNumber = "18"
|
|
18
|
+
endingLineNumber = "18"
|
|
19
|
+
landmarkName = "Penthera"
|
|
20
|
+
landmarkType = "3">
|
|
21
|
+
</BreakpointContent>
|
|
22
|
+
</BreakpointProxy>
|
|
23
|
+
<BreakpointProxy
|
|
24
|
+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
25
|
+
<BreakpointContent
|
|
26
|
+
uuid = "5D7AE47B-D5FC-4468-A75B-C414F3F8A58C"
|
|
27
|
+
shouldBeEnabled = "No"
|
|
28
|
+
ignoreCount = "0"
|
|
29
|
+
continueAfterRunningActions = "No"
|
|
30
|
+
filePath = "Penthera.swift"
|
|
31
|
+
startingColumnNumber = "9223372036854775807"
|
|
32
|
+
endingColumnNumber = "9223372036854775807"
|
|
33
|
+
startingLineNumber = "25"
|
|
34
|
+
endingLineNumber = "25"
|
|
35
|
+
landmarkName = "updateStatusInfo()"
|
|
36
|
+
landmarkType = "7">
|
|
37
|
+
</BreakpointContent>
|
|
38
|
+
</BreakpointProxy>
|
|
39
|
+
<BreakpointProxy
|
|
40
|
+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
41
|
+
<BreakpointContent
|
|
42
|
+
uuid = "E3C50B30-46CF-4D56-8C49-C257C70E0ACC"
|
|
43
|
+
shouldBeEnabled = "No"
|
|
44
|
+
ignoreCount = "0"
|
|
45
|
+
continueAfterRunningActions = "No"
|
|
46
|
+
filePath = "Penthera.swift"
|
|
47
|
+
startingColumnNumber = "9223372036854775807"
|
|
48
|
+
endingColumnNumber = "9223372036854775807"
|
|
49
|
+
startingLineNumber = "26"
|
|
50
|
+
endingLineNumber = "26"
|
|
51
|
+
landmarkName = "updateStatusInfo()"
|
|
52
|
+
landmarkType = "7">
|
|
53
|
+
</BreakpointContent>
|
|
54
|
+
</BreakpointProxy>
|
|
55
|
+
<BreakpointProxy
|
|
56
|
+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
57
|
+
<BreakpointContent
|
|
58
|
+
uuid = "75EF43BF-56FF-4727-B372-E1A0EBC02C61"
|
|
59
|
+
shouldBeEnabled = "Yes"
|
|
60
|
+
ignoreCount = "0"
|
|
61
|
+
continueAfterRunningActions = "No"
|
|
62
|
+
filePath = "Penthera.swift"
|
|
63
|
+
startingColumnNumber = "9223372036854775807"
|
|
64
|
+
endingColumnNumber = "9223372036854775807"
|
|
65
|
+
startingLineNumber = "101"
|
|
66
|
+
endingLineNumber = "101"
|
|
67
|
+
landmarkName = "initializeSdk(user:backplaneUrl:publicKey:privateKey:resolve:reject:)"
|
|
68
|
+
landmarkType = "7">
|
|
69
|
+
</BreakpointContent>
|
|
70
|
+
</BreakpointProxy>
|
|
71
|
+
<BreakpointProxy
|
|
72
|
+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
73
|
+
<BreakpointContent
|
|
74
|
+
uuid = "EF36B51B-4FC2-4989-A791-180E3212EFE3"
|
|
75
|
+
shouldBeEnabled = "Yes"
|
|
76
|
+
ignoreCount = "0"
|
|
77
|
+
continueAfterRunningActions = "No"
|
|
78
|
+
filePath = "Penthera.swift"
|
|
79
|
+
startingColumnNumber = "9223372036854775807"
|
|
80
|
+
endingColumnNumber = "9223372036854775807"
|
|
81
|
+
startingLineNumber = "149"
|
|
82
|
+
endingLineNumber = "149"
|
|
83
|
+
landmarkName = "getDownloadedAsset(assetID:)"
|
|
84
|
+
landmarkType = "7">
|
|
85
|
+
</BreakpointContent>
|
|
86
|
+
</BreakpointProxy>
|
|
87
|
+
<BreakpointProxy
|
|
88
|
+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
89
|
+
<BreakpointContent
|
|
90
|
+
uuid = "C467C00E-2428-4D24-843A-E7CDF28CB553"
|
|
91
|
+
shouldBeEnabled = "Yes"
|
|
92
|
+
ignoreCount = "0"
|
|
93
|
+
continueAfterRunningActions = "No"
|
|
94
|
+
filePath = "Penthera.swift"
|
|
95
|
+
startingColumnNumber = "9223372036854775807"
|
|
96
|
+
endingColumnNumber = "9223372036854775807"
|
|
97
|
+
startingLineNumber = "148"
|
|
98
|
+
endingLineNumber = "148"
|
|
99
|
+
landmarkName = "getDownloadedAsset(assetID:)"
|
|
100
|
+
landmarkType = "7">
|
|
101
|
+
</BreakpointContent>
|
|
102
|
+
</BreakpointProxy>
|
|
103
|
+
</Breakpoints>
|
|
104
|
+
</Bucket>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Penthera.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
@@ -6,13 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.usePenthera = void 0;
|
|
7
7
|
var _zustand = require("zustand");
|
|
8
8
|
var _nativeModules = require("../../nativeModules");
|
|
9
|
-
const usePenthera = (0, _zustand.create)(set => ({
|
|
9
|
+
const usePenthera = (0, _zustand.create)((set, get) => ({
|
|
10
10
|
assets: [],
|
|
11
11
|
assetsProgress: {},
|
|
12
|
-
assetError:
|
|
13
|
-
assetId: '',
|
|
14
|
-
description: ''
|
|
15
|
-
},
|
|
12
|
+
assetError: [],
|
|
16
13
|
assetsPending: [],
|
|
17
14
|
loadAssets: assets => set(() => ({
|
|
18
15
|
assets
|
|
@@ -70,12 +67,11 @@ const usePenthera = (0, _zustand.create)(set => ({
|
|
|
70
67
|
drm
|
|
71
68
|
}));
|
|
72
69
|
return set(state => ({
|
|
73
|
-
assets: [...state.assets,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
assetsPending: state.assetsPending.filter(asset => asset.id !== item.id)
|
|
70
|
+
assets: [...state.assets, {
|
|
71
|
+
...item,
|
|
72
|
+
id: item.data.mediaId
|
|
73
|
+
}],
|
|
74
|
+
assetsPending: state.assetsPending.filter(asset => asset.id !== item.data.mediaId)
|
|
79
75
|
}));
|
|
80
76
|
} catch (error) {
|
|
81
77
|
console.error('error: downloadAsset', error);
|
|
@@ -83,8 +79,10 @@ const usePenthera = (0, _zustand.create)(set => ({
|
|
|
83
79
|
},
|
|
84
80
|
deleteMany: async assetIds => {
|
|
85
81
|
try {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
82
|
+
const vpids = assetIds.map(assetId => get().getVpidByMediaId(assetId));
|
|
83
|
+
const response = await (0, _nativeModules.deleteMany)(vpids);
|
|
84
|
+
const vpidsDeleted = Object.keys(response).filter(item => response[item]);
|
|
85
|
+
const deleted = vpidsDeleted.map(assetId => get().getMediaIdByVpid(assetId));
|
|
88
86
|
return set(state => {
|
|
89
87
|
const updatedAssetsProgress = {
|
|
90
88
|
...state.assetsProgress
|
|
@@ -108,16 +106,31 @@ const usePenthera = (0, _zustand.create)(set => ({
|
|
|
108
106
|
},
|
|
109
107
|
onPlayVideo: async assetId => {
|
|
110
108
|
try {
|
|
111
|
-
const
|
|
109
|
+
const vpid = get().getVpidByMediaId(assetId);
|
|
110
|
+
const response = await (0, _nativeModules.playAsset)(vpid);
|
|
112
111
|
return response;
|
|
113
112
|
} catch (error) {
|
|
114
113
|
console.log('error in onPlayVideo', error);
|
|
115
114
|
return {};
|
|
116
115
|
}
|
|
117
116
|
},
|
|
118
|
-
setError:
|
|
119
|
-
return set(
|
|
120
|
-
assetError
|
|
117
|
+
setError: dataError => {
|
|
118
|
+
return set(state => {
|
|
119
|
+
const assetIdExists = state.assetError.some(error => error.assetId === dataError.assetId);
|
|
120
|
+
if (!assetIdExists) {
|
|
121
|
+
return {
|
|
122
|
+
assetError: [...state.assetError, {
|
|
123
|
+
...dataError
|
|
124
|
+
}],
|
|
125
|
+
assetsProgress: {}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return state;
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
removeError: assetIdToRemove => {
|
|
132
|
+
return set(state => ({
|
|
133
|
+
assetError: state.assetError.filter(error => error.assetId !== assetIdToRemove),
|
|
121
134
|
assetsProgress: {}
|
|
122
135
|
}));
|
|
123
136
|
},
|
|
@@ -138,6 +151,14 @@ const usePenthera = (0, _zustand.create)(set => ({
|
|
|
138
151
|
set(state => ({
|
|
139
152
|
assetsPending: state.assetsPending.filter(asset => asset.id !== assetId)
|
|
140
153
|
}));
|
|
154
|
+
},
|
|
155
|
+
getVpidByMediaId: mediaId => {
|
|
156
|
+
var _get$assets$find, _get$assets$find$data;
|
|
157
|
+
return ((_get$assets$find = get().assets.find(item => item.data.mediaId === mediaId)) === null || _get$assets$find === void 0 ? void 0 : (_get$assets$find$data = _get$assets$find.data) === null || _get$assets$find$data === void 0 ? void 0 : _get$assets$find$data.vpid) ?? '';
|
|
158
|
+
},
|
|
159
|
+
getMediaIdByVpid: vpid => {
|
|
160
|
+
var _get$assets, _get$assets$find2, _get$assets$find2$dat;
|
|
161
|
+
return ((_get$assets = get().assets) === null || _get$assets === void 0 ? void 0 : (_get$assets$find2 = _get$assets.find(item => item.data.vpid === vpid)) === null || _get$assets$find2 === void 0 ? void 0 : (_get$assets$find2$dat = _get$assets$find2.data) === null || _get$assets$find2$dat === void 0 ? void 0 : _get$assets$find2$dat.mediaId) ?? '';
|
|
141
162
|
}
|
|
142
163
|
}));
|
|
143
164
|
exports.usePenthera = usePenthera;
|