@takeoffmedia/react-native-penthera 0.1.12 → 0.1.13
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 +36 -49
- package/package.json +1 -1
package/ios/Penthera.swift
CHANGED
|
@@ -115,15 +115,39 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
115
115
|
offlineCatalogs.append(catalog)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
for case let va as VirtuosoAsset in pendingAssets {
|
|
119
|
+
|
|
120
|
+
let thumbnail = va.findAllAncillaries(withTag: "thumbnail").first
|
|
121
|
+
let show = va.findAllAncillaries(withTag: "show").first
|
|
122
|
+
let thumbnails = Thumbnails(
|
|
123
|
+
thumbnail: thumbnail?.fileDownloadURL ?? "",
|
|
124
|
+
show: show?.fileDownloadURL ?? ""
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
let expiryDate = va.expiryDate // Assuming this is a valid Date object
|
|
128
|
+
let effectiveExpiryDate = va.effectiveExpiryDate // Assuming this is a valid Date object
|
|
129
|
+
let dataItem = DataItem(
|
|
130
|
+
title: va.userInfo?["title"] as? String,
|
|
131
|
+
seasonId: va.userInfo?["seasonId"] as? String,
|
|
132
|
+
seasonTitle: va.userInfo?["seasonTitle"] as? String,
|
|
133
|
+
duration: va.duration,
|
|
134
|
+
estimatedSize: Int(va.estimatedSize),
|
|
135
|
+
dataOffers: parseDataOffer(offer: va.userInfo?["dataOffers"] as Any),
|
|
136
|
+
expiryAfterPlay: timeIntervalToString(va.expiryAfterPlay),
|
|
137
|
+
expiryAfterDownload: timeIntervalToString(va.expiryAfterDownload),
|
|
138
|
+
isExpired: va.isExpired
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
let catalog = OfflineCatalog(
|
|
142
|
+
id: va.assetID,
|
|
143
|
+
title: va.description,
|
|
144
|
+
data: dataItem,
|
|
145
|
+
thumbnails: thumbnails,
|
|
146
|
+
isCompleted: false,
|
|
147
|
+
isPaused: va.isPaused
|
|
148
|
+
)
|
|
149
|
+
offlineCatalogs.append(catalog)
|
|
150
|
+
}
|
|
127
151
|
|
|
128
152
|
let decoder = JSONEncoder()
|
|
129
153
|
do {
|
|
@@ -150,47 +174,10 @@ class Penthera: RCTEventEmitter, VirtuosoDownloadEngineNotificationsDelegate {
|
|
|
150
174
|
}
|
|
151
175
|
|
|
152
176
|
public func downloadEngineProgressUpdated(for asset: VirtuosoAsset) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
let thumbnails = Thumbnails(
|
|
157
|
-
thumbnail: thumbnail?.fileDownloadURL ?? "",
|
|
158
|
-
show: show?.fileDownloadURL ?? ""
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
let dataItem = DataItem(
|
|
162
|
-
title: asset.userInfo?["title"] as? String,
|
|
163
|
-
seasonId: asset.userInfo?["seasonId"] as? String,
|
|
164
|
-
seasonTitle: asset.userInfo?["seasonTitle"] as? String
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
let dataParse = StatusDownload(
|
|
168
|
-
id: asset.assetID,
|
|
169
|
-
title: asset.description,
|
|
170
|
-
dataOffers: parseDataOffer(offer: asset.userInfo?["dataOffers"] as Any),
|
|
171
|
-
thumbnails: thumbnails,
|
|
172
|
-
duration: asset.duration,
|
|
173
|
-
estimatedSize: Int(asset.estimatedSize),
|
|
174
|
-
progress: Int(asset.fractionComplete*100),
|
|
175
|
-
isCompleted: false,
|
|
176
|
-
isPaused: asset.isPaused,
|
|
177
|
-
data: dataItem
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
let decoder = JSONEncoder()
|
|
181
|
-
do {
|
|
182
|
-
let data = try decoder.encode(dataParse)
|
|
183
|
-
let json = String(data: data, encoding: .utf8)!
|
|
184
|
-
let percentage: Float = Float(asset.fractionComplete)/Float(asset.estimatedSize)
|
|
185
|
-
if(percentage.isFinite) {
|
|
186
|
-
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.PROGRESS_UPDATED, assetId: asset.assetID, body: json)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
} catch {
|
|
190
|
-
print("Error converting to JSON: \(error)")
|
|
177
|
+
let percentage: Float = Float(asset.fractionComplete)/Float(asset.estimatedSize)
|
|
178
|
+
if(percentage.isFinite) {
|
|
179
|
+
EventEmitter.sharedInstance.dispatch(name: "penthera", code: PentheraEvent.PROGRESS_UPDATED, assetId: asset.assetID, body: "\(Int(asset.fractionComplete*100))")
|
|
191
180
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
181
|
}
|
|
195
182
|
|
|
196
183
|
public func downloadEngineProgressUpdatedProcessing(for asset: VirtuosoAsset) {
|