react-native-tpstreams 1.0.6-dev.0 → 1.0.7-debug.1
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.
|
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
|
|
|
21
21
|
'DEFINES_MODULE' => 'YES',
|
|
22
22
|
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES'
|
|
23
23
|
}
|
|
24
|
-
s.dependency "TPStreamsSDK" , "1.2.
|
|
24
|
+
s.dependency "TPStreamsSDK" , "1.2.11"
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
# Ensure the module is not built as a framework to avoid bridging header conflicts
|
|
@@ -140,7 +140,7 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
140
140
|
// Send initial events
|
|
141
141
|
emitEvent("onPlayerStateChanged", mapOf("playbackState" to 0))
|
|
142
142
|
emitEvent("onIsPlayingChanged", mapOf("isPlaying" to false))
|
|
143
|
-
emitEvent("onPlaybackSpeedChanged", mapOf("speed" to 1.0))
|
|
143
|
+
// emitEvent("onPlaybackSpeedChanged", mapOf("speed" to 1.0))
|
|
144
144
|
emitEvent("onIsLoadingChanged", mapOf("isLoading" to false))
|
|
145
145
|
} catch (e: Exception) {
|
|
146
146
|
Log.e("TPStreamsRN", "Error creating player", e)
|
|
@@ -6,6 +6,8 @@ import AVFoundation
|
|
|
6
6
|
|
|
7
7
|
@objc(TPStreamsRNPlayerView)
|
|
8
8
|
class TPStreamsRNPlayerView: UIView {
|
|
9
|
+
|
|
10
|
+
private static let errorCodeDRMLicenseExpired = 5100
|
|
9
11
|
|
|
10
12
|
private enum PlaybackState: Int {
|
|
11
13
|
case idle = 1
|
|
@@ -21,6 +23,7 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
21
23
|
private var timeControlStatusObserver: NSKeyValueObservation?
|
|
22
24
|
private var playerStateObserver: NSKeyValueObservation?
|
|
23
25
|
private var setupScheduled = false
|
|
26
|
+
private var pendingOfflineCredentialsCompletion: ((String?, Double) -> Void)?
|
|
24
27
|
|
|
25
28
|
@objc var videoId: NSString = ""
|
|
26
29
|
@objc var accessToken: NSString = ""
|
|
@@ -142,6 +145,15 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
142
145
|
|
|
143
146
|
private func configurePlayerView() {
|
|
144
147
|
guard let player = player else { return }
|
|
148
|
+
player.onRequestOfflineLicenseRenewal = { [weak self] assetId, completion in
|
|
149
|
+
guard let self = self else {
|
|
150
|
+
completion(nil, 0)
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
self.sendErrorEvent("Playback error", Self.errorCodeDRMLicenseExpired, "Offline DRM license expired")
|
|
154
|
+
self.pendingOfflineCredentialsCompletion = completion
|
|
155
|
+
self.onAccessTokenExpired?(["videoId": assetId])
|
|
156
|
+
}
|
|
145
157
|
|
|
146
158
|
let configBuilder = createPlayerConfigBuilder()
|
|
147
159
|
let playerVC = TPStreamPlayerViewController()
|
|
@@ -162,6 +174,10 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
162
174
|
.setprogressBarThumbColor(.systemBlue)
|
|
163
175
|
.setwatchedProgressTrackColor(.systemBlue)
|
|
164
176
|
.setDownloadMetadata(metadataDict)
|
|
177
|
+
|
|
178
|
+
if offlineLicenseExpireTime > 0 {
|
|
179
|
+
configBuilder.setLicenseDurationSeconds(offlineLicenseExpireTime)
|
|
180
|
+
}
|
|
165
181
|
|
|
166
182
|
if enableDownload {
|
|
167
183
|
configBuilder.showDownloadOption()
|
|
@@ -239,19 +255,27 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
239
255
|
}
|
|
240
256
|
}
|
|
241
257
|
|
|
258
|
+
private func sendErrorEvent(_ message: String, _ code: Int, _ details: String) {
|
|
259
|
+
onError?([
|
|
260
|
+
"message": message,
|
|
261
|
+
"code": code,
|
|
262
|
+
"details": details
|
|
263
|
+
])
|
|
264
|
+
}
|
|
265
|
+
|
|
242
266
|
private func mapPlayerStateToAndroid(_ status: AVPlayer.Status, timeControlStatus: AVPlayer.TimeControlStatus? = nil) -> Int {
|
|
243
267
|
switch status {
|
|
244
268
|
case .unknown:
|
|
245
|
-
return PlaybackState.idle.rawValue
|
|
269
|
+
return PlaybackState.idle.rawValue
|
|
246
270
|
case .readyToPlay:
|
|
247
271
|
if timeControlStatus == .waitingToPlayAtSpecifiedRate {
|
|
248
|
-
return PlaybackState.buffering.rawValue
|
|
272
|
+
return PlaybackState.buffering.rawValue
|
|
249
273
|
}
|
|
250
|
-
return PlaybackState.ready.rawValue
|
|
274
|
+
return PlaybackState.ready.rawValue
|
|
251
275
|
case .failed:
|
|
252
|
-
return PlaybackState.idle.rawValue
|
|
276
|
+
return PlaybackState.idle.rawValue
|
|
253
277
|
@unknown default:
|
|
254
|
-
return PlaybackState.idle.rawValue
|
|
278
|
+
return PlaybackState.idle.rawValue
|
|
255
279
|
}
|
|
256
280
|
}
|
|
257
281
|
|
|
@@ -318,6 +342,12 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
318
342
|
@objc func setNewAccessToken(_ newToken: String) {
|
|
319
343
|
pendingTokenCompletion?(newToken)
|
|
320
344
|
pendingTokenCompletion = nil
|
|
345
|
+
|
|
346
|
+
if let offlineLicenseRenewalCompletion = pendingOfflineCredentialsCompletion {
|
|
347
|
+
let duration = offlineLicenseExpireTime
|
|
348
|
+
offlineLicenseRenewalCompletion(newToken, duration)
|
|
349
|
+
pendingOfflineCredentialsCompletion = nil
|
|
350
|
+
}
|
|
321
351
|
}
|
|
322
352
|
|
|
323
353
|
override func willMove(toSuperview newSuperview: UIView?) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-tpstreams",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7-debug.1",
|
|
4
4
|
"description": "Video component for TPStreams",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -166,5 +166,8 @@
|
|
|
166
166
|
"languages": "kotlin-objc",
|
|
167
167
|
"type": "fabric-view",
|
|
168
168
|
"version": "0.50.3"
|
|
169
|
+
},
|
|
170
|
+
"dependencies": {
|
|
171
|
+
"react-native-tpstreams": "^1.0.7"
|
|
169
172
|
}
|
|
170
173
|
}
|