@takeoffmedia/react-native-penthera 0.1.8 → 0.1.10
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/ios/Penthera.swift +106 -106
- package/package.json +2 -2
package/ios/Penthera.swift
CHANGED
|
@@ -3,19 +3,19 @@ import VirtuosoClientDownloadEngine
|
|
|
3
3
|
@objc(Penthera)
|
|
4
4
|
class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
5
5
|
var downloadEngineNotifications: VirtuosoDownloadEngineNotificationManager!
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
public override init() {
|
|
8
8
|
super.init()
|
|
9
9
|
EventEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
var statusDownload: StatusDownload = StatusDownload()
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
@objc(multiply:withB:withResolver:withRejecter:)
|
|
15
15
|
func multiply(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
|
|
16
16
|
resolve(a*b)
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
@objc(initializeSdk:withBackplaneUrl:withPublicKey:withPrivateKey:withResolver:withRejecter:)
|
|
20
20
|
func initializeSdk(user: String, backplaneUrl: String, publicKey: String, privateKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
21
21
|
guard let engineConfig = VirtuosoEngineConfig(
|
|
@@ -56,13 +56,13 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
@objc(getDownloads:withResolver:withRejecter:)
|
|
61
61
|
func getDownloads(blank: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
62
62
|
let completedAssets = VirtuosoAsset.completedAssets(withAvailabilityFilter: false)
|
|
63
63
|
let pendingAssets = VirtuosoAsset.pendingAssets(withAvailabilityFilter: false)
|
|
64
64
|
var offlineCatalogs: [OfflineCatalog] = []
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
for case let va as VirtuosoAsset in completedAssets {
|
|
67
67
|
let thumbnail = va.findAllAncillaries(withTag: "thumbnail").first
|
|
68
68
|
let show = va.findAllAncillaries(withTag: "show").first
|
|
@@ -70,7 +70,7 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
70
70
|
thumbnail: thumbnail?.fileDownloadURL ?? "",
|
|
71
71
|
show: show?.fileDownloadURL ?? ""
|
|
72
72
|
)
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
let dataItem = DataItem(
|
|
75
75
|
title: va.userInfo?["title"] as? String,
|
|
76
76
|
seasonId: va.userInfo?["seasonId"] as? String,
|
|
@@ -88,17 +88,17 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
88
88
|
isPaused: va.isPaused)
|
|
89
89
|
offlineCatalogs.append(catalog)
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
for case let va as VirtuosoAsset in pendingAssets {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
91
|
+
|
|
92
|
+
// for case let va as VirtuosoAsset in pendingAssets {
|
|
93
|
+
// let catalog = OfflineCatalog(
|
|
94
|
+
// id: va.assetID,
|
|
95
|
+
// data: DataItem(),
|
|
96
|
+
// isCompleted: false,
|
|
97
|
+
// isPaused: va.isPaused
|
|
98
|
+
// )
|
|
99
|
+
// offlineCatalogs.append(catalog)
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
102
|
let decoder = JSONEncoder()
|
|
103
103
|
do {
|
|
104
104
|
let data = try decoder.encode(offlineCatalogs)
|
|
@@ -109,7 +109,7 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
109
109
|
}
|
|
110
110
|
//resolve(downloadComplete.map{ ($0 as? VirtuosoAsset)?.assetID })
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
func getDownloadedAsset(assetID: String) -> VirtuosoAsset? {
|
|
114
114
|
// assets that have finished downloading
|
|
115
115
|
let completedAssets = VirtuosoAsset.completedAssets(withAvailabilityFilter: false)
|
|
@@ -118,32 +118,32 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
118
118
|
}
|
|
119
119
|
return asset
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
public func downloadEngineDidStartDownloadingAsset(_ asset: VirtuosoAsset) {
|
|
123
123
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.DID_START_DOWNLOADING, assetId: asset.assetID, body: "")
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
public func downloadEngineProgressUpdated(for asset: VirtuosoAsset) {
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
let thumbnail = asset.findAllAncillaries(withTag: "thumbnail").first
|
|
129
129
|
let show = asset.findAllAncillaries(withTag: "show").first
|
|
130
130
|
let thumbnails = Thumbnails(
|
|
131
131
|
thumbnail: thumbnail?.fileDownloadURL ?? "",
|
|
132
132
|
show: show?.fileDownloadURL ?? ""
|
|
133
133
|
)
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
let dataParse = StatusDownload(
|
|
136
136
|
id: asset.assetID,
|
|
137
|
-
title:
|
|
137
|
+
title: asset.userInfo?["title"] as? String ?? "",
|
|
138
138
|
dataOffers: parseDataOffer(offer: asset.userInfo?["dataOffers"] as Any),
|
|
139
139
|
thumbnails: thumbnails,
|
|
140
140
|
duration: asset.duration,
|
|
141
141
|
estimatedSize: Int(asset.estimatedSize),
|
|
142
142
|
progress: Int(asset.fractionComplete*100),
|
|
143
|
-
isCompleted:
|
|
143
|
+
isCompleted: false,
|
|
144
144
|
isPaused: asset.isPaused
|
|
145
145
|
)
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
let decoder = JSONEncoder()
|
|
148
148
|
do {
|
|
149
149
|
let data = try decoder.encode(dataParse)
|
|
@@ -152,33 +152,33 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
152
152
|
if(percentage.isFinite) {
|
|
153
153
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.PROGRESS_UPDATED, assetId: asset.assetID, body: json)
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
} catch {
|
|
157
157
|
print("Error converting to JSON: \(error)")
|
|
158
158
|
}
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
|
|
160
|
+
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
public func downloadEngineProgressUpdatedProcessing(for asset: VirtuosoAsset) {
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
public func downloadEngineDidFinishDownloadingAsset(_ asset: VirtuosoAsset) {
|
|
168
168
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.DOWNLOAD_COMPLETE, assetId: asset.assetID, body: "")
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
|
|
171
171
|
public func downloadEngineDidEncounterError(for asset: VirtuosoAsset, error: Error?, task: URLSessionTask?, data: Data?, statusCode: NSNumber?) {
|
|
172
172
|
asset.delete()
|
|
173
173
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.ERROR_DOWNLOAD, assetId: asset.assetID, body: error.debugDescription ?? "Error downloading")
|
|
174
174
|
/*EventEmitter.sharedInstance.dispatch(name: "penthera", body: "\(asset.assetID): Engine did encounter error \(error?.localizedDescription ?? "-")")*/
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
public func downloadEngineInternalQueueUpdate(asset: VirtuosoAsset) {
|
|
178
178
|
//EventEmitter.sharedInstance.dispatch(name: "penthera", code: "TEST downloadEngineInternalQueueUpdate", body: "Queue updated", assetId: asset.assetID)
|
|
179
179
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: "TEST downloadEngineInternalQueueUpdate", assetId: asset.assetID, body: "Queue updated")
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
public func downloadEngineStartupComplete(_ succeeded: Bool, asset: VirtuosoAsset) {
|
|
183
183
|
//EventEmitter.sharedInstance.dispatch(name: "penthera", code: "Test downloadEngineStartupComplete", body: "SDK startup complete", assetId: asset.assetID)
|
|
184
184
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: "TEST downloadEngineStartupComplete", assetId: asset.assetID, body: "SDK startup complete")
|
|
@@ -203,19 +203,19 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
203
203
|
}
|
|
204
204
|
return ancillaryFiles
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
@objc(download:withResolver:withRejecter:)
|
|
208
208
|
func download(catalogString: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
209
209
|
let virtuoso = VirtuosoDownloadEngine.instance()
|
|
210
210
|
var queue = virtuoso.assetsInQueue()
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
//let decoder = JSONDecoder()
|
|
213
|
-
|
|
213
|
+
|
|
214
214
|
do {
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
|
|
216
|
+
|
|
217
217
|
let data = catalogString.getDictionary()
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
guard let item = data!["item"] as! [String: AnyObject]? else {
|
|
220
220
|
reject("No item", nil, nil)
|
|
221
221
|
return
|
|
@@ -224,20 +224,20 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
224
224
|
reject("No url", nil, nil)
|
|
225
225
|
return
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
let assetID = item["id"] as! String? ?? ""
|
|
229
229
|
let hasDRM = item["drm"] as! Bool? ?? false
|
|
230
230
|
let title = item["title"] as! String? ?? ""
|
|
231
|
-
|
|
231
|
+
|
|
232
232
|
let downloadAsset = getDownloadedAsset(assetID: assetID)
|
|
233
233
|
let pendingAsset = getPendingAsset(assetID: assetID)
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
if (pendingAsset != nil) {
|
|
236
236
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.PENDING_ASSET_FOUND, assetId: assetID, body: "")
|
|
237
237
|
pendingAsset?.delete()
|
|
238
238
|
return
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
|
|
241
241
|
if(downloadAsset == nil && pendingAsset == nil) {
|
|
242
242
|
DispatchQueue.global(qos: .background).async {
|
|
243
243
|
guard let config = VirtuosoAssetConfig(url: url,
|
|
@@ -251,69 +251,69 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
251
251
|
let thumbnails = item["thumbnails"] as! [String: AnyObject]? ?? [:]
|
|
252
252
|
let subtitles = item["subtitles"] as! [String: AnyObject]? ?? [:]
|
|
253
253
|
config.ancillaries = self.getAncillaryFiles(files: thumbnails) + self.getAncillaryFiles(files: subtitles)
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
|
|
255
|
+
|
|
256
256
|
//DRM
|
|
257
257
|
if(hasDRM) {
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
guard let drm = data!["drm"] as! [String: AnyObject]? else {
|
|
260
260
|
reject("No drm", nil, nil)
|
|
261
261
|
return
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
|
|
264
264
|
let token = drm["token"] as! String? ?? ""
|
|
265
265
|
let licenceHttpHeader = drm["licence_server_http_header"] as! String? ?? ""
|
|
266
266
|
let licence = drm["licence_server"] as! String? ?? ""
|
|
267
267
|
let cert = drm["fairplay_cert"] as! String? ?? ""
|
|
268
|
-
|
|
268
|
+
|
|
269
269
|
guard let drmSetup = FairPlayDrmSetup(assetID: assetID, certificateUrl: cert, licenceUrl: licence, header: licenceHttpHeader, token: token) else {
|
|
270
270
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.FAIR_PLAY_LICENSE_DELEGATE_ERROR, assetId: "", body: "")
|
|
271
271
|
return
|
|
272
272
|
}
|
|
273
|
-
|
|
273
|
+
|
|
274
274
|
if !drmSetup.configure() {
|
|
275
275
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.FAIR_PLAY_LICENSE_DELEGATE_ERROR, assetId: "", body: "")
|
|
276
276
|
return
|
|
277
277
|
}
|
|
278
278
|
config.protectionType = .vde_AssetProtectionTypeFairPlay
|
|
279
|
-
|
|
279
|
+
|
|
280
280
|
}
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
let asset = VirtuosoAsset.init(config: config)
|
|
283
|
-
|
|
283
|
+
|
|
284
284
|
let data = item["data"] as! [String: AnyObject]? ?? [:]
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
asset?.userInfo = data
|
|
287
|
-
|
|
287
|
+
|
|
288
288
|
config.ancillaries?.forEach{ file in
|
|
289
289
|
asset?.add(file)
|
|
290
290
|
}
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
|
|
292
|
+
|
|
293
293
|
//asset?.add(subtitle!)
|
|
294
|
-
|
|
294
|
+
|
|
295
295
|
//let calendar = Calendar.current
|
|
296
296
|
//guard let expiryDate = calendar.date(byAdding: .minute, value: 1, to: Date()) else {
|
|
297
297
|
// return
|
|
298
298
|
//}
|
|
299
|
-
|
|
299
|
+
|
|
300
300
|
//asset?.expiryAfterDownload = expiryDate.timeIntervalSinceNow
|
|
301
|
-
|
|
301
|
+
|
|
302
302
|
queue.append(asset!)
|
|
303
303
|
resolve(assetID)
|
|
304
304
|
//resolve(queue.count)
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
|
|
307
|
+
|
|
308
308
|
} catch {
|
|
309
309
|
reject("penthera", error.localizedDescription, error)
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
|
|
312
|
+
|
|
313
313
|
@objc(delete:withResolver:withRejecter:)
|
|
314
314
|
func delete(assetID: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
315
315
|
//DispatchQueue.global(qos: .background).async {
|
|
316
|
-
|
|
316
|
+
|
|
317
317
|
let downloadComplete = VirtuosoAsset.completedAssets(withAvailabilityFilter: false)
|
|
318
318
|
if(downloadComplete.count > 0) {
|
|
319
319
|
for case let va as VirtuosoAsset in downloadComplete {
|
|
@@ -328,14 +328,14 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
328
328
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.ASSET_DELETED, assetId: assetID, body: "")
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
334
|
@objc(deleteMany:withResolver:withRejecter:)
|
|
335
335
|
func deleteMany(assetIDS: [String], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
336
336
|
// initialize assetResponse {}. Ex {"123":false, "543":false}
|
|
337
337
|
var assetsResponse: [String: Bool] = Dictionary(uniqueKeysWithValues: assetIDS.map { ($0, false) })
|
|
338
|
-
|
|
338
|
+
|
|
339
339
|
let downloadComplete = VirtuosoAsset.completedAssets(withAvailabilityFilter: false)
|
|
340
340
|
if(downloadComplete.count > 0) {
|
|
341
341
|
var assetsToDelete: [VirtuosoAsset] = []
|
|
@@ -348,8 +348,8 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
|
|
352
|
+
|
|
353
353
|
VirtuosoAsset.delete(assetsToDelete) { () in
|
|
354
354
|
resolve(assetsResponse)
|
|
355
355
|
}
|
|
@@ -361,85 +361,85 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
361
361
|
reject("ASSET_DELETE_ERROR", errorMessage, error)
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
367
|
@objc open override func supportedEvents() -> [String] {
|
|
368
368
|
return EventEmitter.sharedInstance.allEvents
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
|
|
371
371
|
@objc(playAsset:withResolver:withRejecter:)
|
|
372
372
|
func playAsset(assetID: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
373
|
-
|
|
373
|
+
|
|
374
374
|
let downloadComplete = VirtuosoAsset.completedAssets(withAvailabilityFilter: false)
|
|
375
375
|
guard let asset = downloadComplete.filter({ ($0 as! VirtuosoAsset).assetID == assetID }).first as? VirtuosoAsset else {
|
|
376
376
|
reject("Error streaming asset", "", nil)
|
|
377
377
|
return
|
|
378
378
|
}
|
|
379
|
-
|
|
379
|
+
|
|
380
380
|
let decoder = JSONEncoder()
|
|
381
|
-
|
|
381
|
+
|
|
382
382
|
do {
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
|
|
384
|
+
|
|
385
385
|
// let subtitle = vcHttpServer?.ancillaryURLForAncillary(withTag: "subtitle", usingMime: "text/vtt")
|
|
386
386
|
// let thumbnailOffline = asset.findAllAncillaries(withTag: "thumbnailOffline").first
|
|
387
387
|
//let wallpaper = asset.findAllAncillaries(withTag: "wallpaper").first
|
|
388
|
-
|
|
388
|
+
|
|
389
389
|
let vcHttpServer = VirtuosoClientHTTPServer(asset: asset)
|
|
390
|
-
|
|
390
|
+
|
|
391
391
|
let licenseURL = vcHttpServer?.fairPlayLicenseServerURL
|
|
392
392
|
let certificateURL = vcHttpServer?.fairPlayCertificateDataURL(forSubType: nil)
|
|
393
|
-
|
|
393
|
+
|
|
394
394
|
//let avContentKeySession = VirtuosoLicenseManager.registeredAVContentKeySession()
|
|
395
|
-
|
|
395
|
+
|
|
396
396
|
//let userInfoData = try encoder.encode(asset.userInfo)
|
|
397
397
|
//let userInfo = String(data: userInfoData, encoding: .utf8)
|
|
398
|
-
|
|
398
|
+
|
|
399
399
|
let assetData = [
|
|
400
400
|
"id": asset.assetID,
|
|
401
401
|
"url": vcHttpServer?.playbackURL ?? "",
|
|
402
402
|
"certificate": certificateURL ,
|
|
403
403
|
"license": licenseURL
|
|
404
404
|
]
|
|
405
|
-
|
|
405
|
+
|
|
406
406
|
let data = try decoder.encode(assetData)
|
|
407
407
|
let json = String(data: data, encoding: .utf8)!
|
|
408
408
|
resolve(json)
|
|
409
|
-
|
|
409
|
+
|
|
410
410
|
// let config = PlayerConfig()
|
|
411
411
|
// config.styleConfig.userInterfaceType = .system
|
|
412
412
|
// config.key = "ASSSSSS"
|
|
413
|
-
|
|
413
|
+
|
|
414
414
|
// let player = PlayerFactory.create(playerConfig: config)
|
|
415
|
-
|
|
415
|
+
|
|
416
416
|
// guard let streamUrl = URL(string: vcHttpServer!.playbackURL) else {
|
|
417
417
|
// return
|
|
418
418
|
// }
|
|
419
|
-
|
|
419
|
+
|
|
420
420
|
// // Create a SourceConfig
|
|
421
421
|
// let sourceConfig = SourceConfig(url: streamUrl, type: .hls)
|
|
422
422
|
// print(streamUrl.absoluteString)
|
|
423
|
-
|
|
423
|
+
|
|
424
424
|
// // Optionally set additional properties
|
|
425
425
|
// sourceConfig.title = "Art of motion"
|
|
426
|
-
|
|
426
|
+
|
|
427
427
|
// DispatchQueue.main.async {
|
|
428
428
|
// let source = SourceFactory.create(from: sourceConfig)
|
|
429
|
-
|
|
429
|
+
|
|
430
430
|
// player.load(source: source)
|
|
431
|
-
|
|
432
|
-
|
|
431
|
+
|
|
432
|
+
|
|
433
433
|
// let viewController = UIApplication.shared.windows.first?.rootViewController as? UIViewController
|
|
434
|
-
|
|
434
|
+
|
|
435
435
|
// let playerView = PlayerView(player: player, frame: (viewController?.view.bounds)!)
|
|
436
|
-
|
|
436
|
+
|
|
437
437
|
// // Adding the view to the a container View
|
|
438
438
|
// viewController?.view.addSubview(playerView)
|
|
439
439
|
// viewController?.view.bringSubviewToFront(playerView)
|
|
440
440
|
// }
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
|
|
442
|
+
|
|
443
443
|
/*
|
|
444
444
|
let demoPlayer = DemoPlayerViewController()
|
|
445
445
|
DispatchQueue.main.async {
|
|
@@ -447,7 +447,7 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
447
447
|
andPlayer: demoPlayer as VirtuosoPlayer,
|
|
448
448
|
onSuccess: {
|
|
449
449
|
// Present the player
|
|
450
|
-
|
|
450
|
+
|
|
451
451
|
let viewController = UIApplication.shared.windows.first?.rootViewController as? UIViewController
|
|
452
452
|
viewController?.present(demoPlayer, animated: true)
|
|
453
453
|
//self.present(demoPlayer, animated: true, completion: nil)
|
|
@@ -456,13 +456,13 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
456
456
|
//self.error = nil
|
|
457
457
|
})
|
|
458
458
|
}*/
|
|
459
|
-
|
|
459
|
+
|
|
460
460
|
} catch {
|
|
461
461
|
reject("penthere", error.localizedDescription, error)
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
|
|
465
|
+
|
|
466
466
|
@objc(pauseDownload:withResolver:withRejecter:)
|
|
467
467
|
func pauseDownload(assetID: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
468
468
|
let pendingAsset = getPendingAsset(assetID: assetID)
|
|
@@ -470,13 +470,13 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
470
470
|
self.pauseAsset(asset: pendingAsset!)
|
|
471
471
|
return
|
|
472
472
|
}
|
|
473
|
-
|
|
473
|
+
|
|
474
474
|
}
|
|
475
|
-
|
|
475
|
+
|
|
476
476
|
func pauseAsset(asset: VirtuosoAsset) {
|
|
477
477
|
asset.isPaused = !asset.isPaused
|
|
478
478
|
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.ASSET_RESUME_DOWNLOAD_UPDATED, assetId: asset.assetID, body: "\(asset.isPaused)")
|
|
479
479
|
}
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
|
|
481
|
+
|
|
482
482
|
}
|
package/package.json
CHANGED