react-native-tpstreams 1.0.1 → 1.0.3
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/TPStreamsRNPlayerView.podspec +1 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt +44 -34
- package/ios/TPStreamsDownloadModule.swift +61 -4
- package/ios/TPStreamsModule.swift +5 -0
- package/ios/TPStreamsRNPlayerView.swift +33 -4
- package/ios/TPStreamsRNPlayerViewManager.m +1 -0
- package/lib/module/TPStreamsDownload.js +5 -0
- package/lib/module/TPStreamsDownload.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/TPStreamsDownload.d.ts +6 -0
- package/lib/typescript/src/TPStreamsDownload.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TPStreamsDownload.tsx +18 -0
- package/src/index.tsx +2 -0
|
@@ -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.8"
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
# Ensure the module is not built as a framework to avoid bridging header conflicts
|
|
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.Arguments
|
|
|
6
6
|
import com.facebook.react.bridge.ReactMethod
|
|
7
7
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
8
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
9
|
+
import com.facebook.react.bridge.WritableMap
|
|
9
10
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
10
11
|
import com.tpstreams.player.download.DownloadClient
|
|
11
12
|
import com.tpstreams.player.download.DownloadItem
|
|
@@ -68,31 +69,56 @@ class TPStreamsDownloadModule(private val reactContext: ReactApplicationContext)
|
|
|
68
69
|
|
|
69
70
|
val result = Arguments.createArray()
|
|
70
71
|
for (item in currentDownloads) {
|
|
71
|
-
val map =
|
|
72
|
-
map.putString("videoId", item.assetId)
|
|
73
|
-
map.putString("title", item.title)
|
|
74
|
-
item.thumbnailUrl?.let { map.putString("thumbnailUrl", it) }
|
|
75
|
-
map.putDouble("totalBytes", item.totalBytes.toDouble())
|
|
76
|
-
map.putDouble("downloadedBytes", item.downloadedBytes.toDouble())
|
|
77
|
-
map.putDouble("progressPercentage", item.progressPercentage.toDouble())
|
|
78
|
-
map.putString("state", downloadClient.getDownloadStatus(item.assetId))
|
|
79
|
-
|
|
80
|
-
val metadataJson = org.json.JSONObject()
|
|
81
|
-
item.metadata.forEach { (key, value) ->
|
|
82
|
-
metadataJson.put(key, value)
|
|
83
|
-
}
|
|
84
|
-
map.putString("metadata", metadataJson.toString())
|
|
85
|
-
|
|
72
|
+
val map = createDownloadItemMap(item)
|
|
86
73
|
result.pushMap(map)
|
|
87
74
|
}
|
|
88
|
-
|
|
89
75
|
emitEvent("onDownloadProgressChanged", result)
|
|
90
|
-
|
|
91
76
|
} catch (e: Exception) {
|
|
92
77
|
Log.e(TAG, "Error in onDownloadsChanged: ${e.message}", e)
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
80
|
|
|
81
|
+
override fun onDownloadStateChanged(downloadItem: DownloadItem, error: Exception?) {
|
|
82
|
+
try {
|
|
83
|
+
val map = Arguments.createMap()
|
|
84
|
+
val downloadItemMap = createDownloadItemMap(downloadItem)
|
|
85
|
+
map.putMap("downloadItem", downloadItemMap)
|
|
86
|
+
|
|
87
|
+
if (error != null) {
|
|
88
|
+
val errorMap = Arguments.createMap()
|
|
89
|
+
errorMap.putString("message", error.message ?: "Unknown error")
|
|
90
|
+
errorMap.putString("type", error.javaClass.simpleName)
|
|
91
|
+
map.putMap("error", errorMap)
|
|
92
|
+
} else {
|
|
93
|
+
map.putNull("error")
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
emitEvent("onDownloadStateChanged", map)
|
|
97
|
+
|
|
98
|
+
} catch (e: Exception) {
|
|
99
|
+
Log.e(TAG, "Error in onDownloadStateChanged: ${e.message}", e)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private fun createDownloadItemMap(item: DownloadItem): WritableMap {
|
|
104
|
+
val map = Arguments.createMap()
|
|
105
|
+
map.putString("videoId", item.assetId)
|
|
106
|
+
map.putString("title", item.title)
|
|
107
|
+
item.thumbnailUrl?.let { map.putString("thumbnailUrl", it) }
|
|
108
|
+
map.putDouble("totalBytes", item.totalBytes.toDouble())
|
|
109
|
+
map.putDouble("downloadedBytes", item.downloadedBytes.toDouble())
|
|
110
|
+
map.putDouble("progressPercentage", item.progressPercentage.toDouble())
|
|
111
|
+
map.putString("state", downloadClient.getDownloadStatus(item.assetId))
|
|
112
|
+
|
|
113
|
+
val metadataJson = org.json.JSONObject()
|
|
114
|
+
item.metadata.forEach { (key, value) ->
|
|
115
|
+
metadataJson.put(key, value)
|
|
116
|
+
}
|
|
117
|
+
map.putString("metadata", metadataJson.toString())
|
|
118
|
+
|
|
119
|
+
return map
|
|
120
|
+
}
|
|
121
|
+
|
|
96
122
|
private fun emitEvent(eventName: String, data: Any) {
|
|
97
123
|
reactContext
|
|
98
124
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
@@ -183,23 +209,7 @@ class TPStreamsDownloadModule(private val reactContext: ReactApplicationContext)
|
|
|
183
209
|
val result = Arguments.createArray()
|
|
184
210
|
|
|
185
211
|
for (item in downloadItems) {
|
|
186
|
-
val map =
|
|
187
|
-
map.putString("videoId", item.assetId)
|
|
188
|
-
map.putString("title", item.title)
|
|
189
|
-
item.thumbnailUrl?.let { map.putString("thumbnailUrl", it) }
|
|
190
|
-
map.putDouble("totalBytes", item.totalBytes.toDouble())
|
|
191
|
-
map.putDouble("downloadedBytes", item.downloadedBytes.toDouble())
|
|
192
|
-
map.putDouble("progressPercentage", item.progressPercentage.toDouble())
|
|
193
|
-
map.putString("state", downloadClient.getDownloadStatus(item.assetId))
|
|
194
|
-
|
|
195
|
-
try {
|
|
196
|
-
val metadataJson = org.json.JSONObject(item.metadata as Map<*, *>)
|
|
197
|
-
map.putString("metadata", metadataJson.toString())
|
|
198
|
-
} catch (e: Exception) {
|
|
199
|
-
Log.w(TAG, "Error serializing metadata for item ${item.assetId}: ${e.message}")
|
|
200
|
-
map.putString("metadata", "{}")
|
|
201
|
-
}
|
|
202
|
-
|
|
212
|
+
val map = createDownloadItemMap(item)
|
|
203
213
|
result.pushMap(map)
|
|
204
214
|
}
|
|
205
215
|
|
|
@@ -3,23 +3,36 @@ import React
|
|
|
3
3
|
import TPStreamsSDK
|
|
4
4
|
|
|
5
5
|
private enum PlayerConstants {
|
|
6
|
-
static let
|
|
6
|
+
static let statusQueued = "Queued"
|
|
7
7
|
static let statusDownloading = "Downloading"
|
|
8
8
|
static let statusPaused = "Paused"
|
|
9
9
|
static let statusCompleted = "Completed"
|
|
10
10
|
static let statusFailed = "Failed"
|
|
11
|
+
static let statusRemoving = "Removing"
|
|
12
|
+
static let statusRestarting = "Restarting"
|
|
11
13
|
static let statusUnknown = "Unknown"
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
protocol TokenRequestDelegate: AnyObject {
|
|
17
|
+
func requestToken(for assetId: String, completion: @escaping (String?) -> Void)
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
@objc(TPStreamsDownload)
|
|
15
21
|
class TPStreamsDownloadModule: RCTEventEmitter, TPStreamsDownloadDelegate {
|
|
16
22
|
|
|
17
23
|
private let downloadManager = TPStreamsDownloadManager.shared
|
|
18
24
|
private var isListening = false
|
|
25
|
+
private var tokenDelegate: TokenRequestDelegate?
|
|
26
|
+
static var shared: TPStreamsDownloadModule?
|
|
19
27
|
|
|
20
28
|
override init() {
|
|
21
29
|
super.init()
|
|
22
30
|
downloadManager.setTPStreamsDownloadDelegate(tpStreamsDownloadDelegate: self)
|
|
31
|
+
TPStreamsDownloadModule.shared = self
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func setAccessTokenDelegate(_ delegate: TokenRequestDelegate) {
|
|
35
|
+
self.tokenDelegate = delegate
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
@objc
|
|
@@ -53,39 +66,57 @@ class TPStreamsDownloadModule: RCTEventEmitter, TPStreamsDownloadDelegate {
|
|
|
53
66
|
|
|
54
67
|
func onDelete(assetId: String) {
|
|
55
68
|
if isListening {
|
|
69
|
+
if let offlineAsset = getOfflineAsset(assetId: assetId) {
|
|
70
|
+
notifyDownloadStateChanged(offlineAsset: offlineAsset)
|
|
71
|
+
}
|
|
56
72
|
notifyDownloadsChange()
|
|
57
73
|
}
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
func onStart(offlineAsset: OfflineAsset) {
|
|
61
77
|
if isListening {
|
|
78
|
+
notifyDownloadStateChanged(offlineAsset: offlineAsset)
|
|
62
79
|
notifyDownloadsChange()
|
|
63
80
|
}
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
func onComplete(offlineAsset: OfflineAsset) {
|
|
67
84
|
if isListening {
|
|
85
|
+
notifyDownloadStateChanged(offlineAsset: offlineAsset)
|
|
68
86
|
notifyDownloadsChange()
|
|
69
87
|
}
|
|
70
88
|
}
|
|
71
89
|
|
|
72
90
|
func onPause(offlineAsset: OfflineAsset) {
|
|
73
91
|
if isListening {
|
|
92
|
+
notifyDownloadStateChanged(offlineAsset: offlineAsset)
|
|
74
93
|
notifyDownloadsChange()
|
|
75
94
|
}
|
|
76
95
|
}
|
|
77
96
|
|
|
78
97
|
func onResume(offlineAsset: OfflineAsset) {
|
|
79
98
|
if isListening {
|
|
99
|
+
notifyDownloadStateChanged(offlineAsset: offlineAsset)
|
|
80
100
|
notifyDownloadsChange()
|
|
81
101
|
}
|
|
82
102
|
}
|
|
83
103
|
|
|
84
104
|
func onCanceled(assetId: String) {
|
|
85
105
|
if isListening {
|
|
106
|
+
if let offlineAsset = getOfflineAsset(assetId: assetId) {
|
|
107
|
+
notifyDownloadStateChanged(offlineAsset: offlineAsset)
|
|
108
|
+
}
|
|
86
109
|
notifyDownloadsChange()
|
|
87
110
|
}
|
|
88
111
|
}
|
|
112
|
+
|
|
113
|
+
func onRequestNewAccessToken(assetId: String, completion: @escaping (String?) -> Void) {
|
|
114
|
+
if let delegate = tokenDelegate {
|
|
115
|
+
delegate.requestToken(for: assetId, completion: completion)
|
|
116
|
+
} else {
|
|
117
|
+
completion(nil)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
89
120
|
|
|
90
121
|
private func notifyDownloadsChange() {
|
|
91
122
|
DispatchQueue.main.async { [weak self] in
|
|
@@ -95,6 +126,28 @@ class TPStreamsDownloadModule: RCTEventEmitter, TPStreamsDownloadDelegate {
|
|
|
95
126
|
}
|
|
96
127
|
}
|
|
97
128
|
|
|
129
|
+
private func notifyDownloadStateChanged(offlineAsset: OfflineAsset, error: Error? = nil) {
|
|
130
|
+
DispatchQueue.main.async { [weak self] in
|
|
131
|
+
guard let self = self else { return }
|
|
132
|
+
|
|
133
|
+
let downloadItem = self.mapOfflineAssetToDict(offlineAsset)
|
|
134
|
+
|
|
135
|
+
var eventData: [String: Any] = [:]
|
|
136
|
+
eventData["downloadItem"] = downloadItem
|
|
137
|
+
|
|
138
|
+
if let error = error {
|
|
139
|
+
eventData["error"] = [
|
|
140
|
+
"message": error.localizedDescription,
|
|
141
|
+
"type": String(describing: type(of: error))
|
|
142
|
+
]
|
|
143
|
+
} else {
|
|
144
|
+
eventData["error"] = NSNull()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
self.sendEvent(withName: "onDownloadStateChanged", body: eventData)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
98
151
|
private func getAllDownloadItems() -> [[String: Any]] {
|
|
99
152
|
let offlineAssets = downloadManager.getAllOfflineAssets()
|
|
100
153
|
return offlineAssets.map { mapOfflineAssetToDict($0) }
|
|
@@ -211,7 +264,7 @@ class TPStreamsDownloadModule: RCTEventEmitter, TPStreamsDownloadDelegate {
|
|
|
211
264
|
if let asset = offlineAssets.first(where: { $0.assetId == videoId }) {
|
|
212
265
|
resolve(mapDownloadStatus(Status(rawValue: asset.status)))
|
|
213
266
|
} else {
|
|
214
|
-
resolve(PlayerConstants.
|
|
267
|
+
resolve(PlayerConstants.statusUnknown)
|
|
215
268
|
}
|
|
216
269
|
}
|
|
217
270
|
}
|
|
@@ -241,13 +294,17 @@ class TPStreamsDownloadModule: RCTEventEmitter, TPStreamsDownloadDelegate {
|
|
|
241
294
|
case .failed:
|
|
242
295
|
return PlayerConstants.statusFailed
|
|
243
296
|
default:
|
|
244
|
-
return PlayerConstants.
|
|
297
|
+
return PlayerConstants.statusUnknown
|
|
245
298
|
}
|
|
246
299
|
}
|
|
247
300
|
|
|
301
|
+
private func getOfflineAsset(assetId: String) -> OfflineAsset? {
|
|
302
|
+
return downloadManager.getAllOfflineAssets().first(where: { $0.assetId == assetId })
|
|
303
|
+
}
|
|
304
|
+
|
|
248
305
|
@objc
|
|
249
306
|
override func supportedEvents() -> [String] {
|
|
250
|
-
return ["onDownloadProgressChanged"]
|
|
307
|
+
return ["onDownloadProgressChanged", "onDownloadStateChanged"]
|
|
251
308
|
}
|
|
252
309
|
|
|
253
310
|
@objc
|
|
@@ -13,10 +13,15 @@ class TPStreamsModule: NSObject {
|
|
|
13
13
|
DispatchQueue.main.async {
|
|
14
14
|
TPStreamsSDK.initialize(withOrgCode: organizationId as String)
|
|
15
15
|
self.isInitialized = true
|
|
16
|
+
self.initializeDownloadModule()
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
private func initializeDownloadModule() {
|
|
22
|
+
let _ = TPStreamsDownloadModule()
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
@objc
|
|
21
26
|
static func requiresMainQueueSetup() -> Bool {
|
|
22
27
|
return true
|
|
@@ -31,6 +31,8 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
31
31
|
@objc var onIsLoadingChanged: RCTDirectEventBlock?
|
|
32
32
|
@objc var onError: RCTDirectEventBlock?
|
|
33
33
|
@objc var onAccessTokenExpired: RCTDirectEventBlock?
|
|
34
|
+
|
|
35
|
+
private var pendingTokenCompletion: ((String?) -> Void)?
|
|
34
36
|
|
|
35
37
|
override init(frame: CGRect) {
|
|
36
38
|
super.init(frame: frame)
|
|
@@ -73,7 +75,7 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
73
75
|
setupScheduled = false
|
|
74
76
|
return
|
|
75
77
|
}
|
|
76
|
-
|
|
78
|
+
setupTokenDelegate()
|
|
77
79
|
configurePlayerView()
|
|
78
80
|
observePlayerChanges()
|
|
79
81
|
setupScheduled = false
|
|
@@ -81,14 +83,19 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
81
83
|
|
|
82
84
|
private func cleanupPlayer() {
|
|
83
85
|
removeObservers()
|
|
86
|
+
player?.pause()
|
|
87
|
+
|
|
84
88
|
playerViewController?.view.removeFromSuperview()
|
|
85
89
|
playerViewController?.removeFromParent()
|
|
86
90
|
playerViewController = nil
|
|
91
|
+
|
|
92
|
+
player?.replaceCurrentItem(with: nil)
|
|
87
93
|
player = nil
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
private func removeObservers() {
|
|
91
97
|
playerStatusObserver?.invalidate()
|
|
98
|
+
playerStatusObserver = nil
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
private func createOfflinePlayer() -> TPAVPlayer? {
|
|
@@ -173,6 +180,10 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
|
|
183
|
+
private func setupTokenDelegate() {
|
|
184
|
+
TPStreamsDownloadModule.shared?.setAccessTokenDelegate(self)
|
|
185
|
+
}
|
|
186
|
+
|
|
176
187
|
private func parseMetadataJSON(from jsonString: NSString?) -> [String: String]? {
|
|
177
188
|
guard let metadataString = jsonString as String? else { return nil }
|
|
178
189
|
|
|
@@ -230,11 +241,29 @@ class TPStreamsRNPlayerView: UIView {
|
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
@objc func setNewAccessToken(_ newToken: String) {
|
|
233
|
-
|
|
234
|
-
|
|
244
|
+
pendingTokenCompletion?(newToken)
|
|
245
|
+
pendingTokenCompletion = nil
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
override func willMove(toSuperview newSuperview: UIView?) {
|
|
249
|
+
if newSuperview == nil {
|
|
250
|
+
cleanupPlayer()
|
|
251
|
+
}
|
|
252
|
+
super.willMove(toSuperview: newSuperview)
|
|
235
253
|
}
|
|
236
254
|
|
|
237
255
|
deinit {
|
|
238
|
-
|
|
256
|
+
cleanupPlayer()
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
extension TPStreamsRNPlayerView: TokenRequestDelegate {
|
|
261
|
+
func requestToken(for assetId: String, completion: @escaping (String?) -> Void) {
|
|
262
|
+
guard let onAccessTokenExpired = onAccessTokenExpired else {
|
|
263
|
+
completion(nil)
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
pendingTokenCompletion = completion
|
|
267
|
+
onAccessTokenExpired(["videoId": assetId])
|
|
239
268
|
}
|
|
240
269
|
}
|
|
@@ -34,5 +34,6 @@ RCT_EXTERN_METHOD(getCurrentPosition:(nonnull NSNumber *)node)
|
|
|
34
34
|
RCT_EXTERN_METHOD(getDuration:(nonnull NSNumber *)node)
|
|
35
35
|
RCT_EXTERN_METHOD(isPlaying:(nonnull NSNumber *)node)
|
|
36
36
|
RCT_EXTERN_METHOD(getPlaybackSpeed:(nonnull NSNumber *)node)
|
|
37
|
+
RCT_EXTERN_METHOD(setNewAccessToken:(nonnull NSNumber *)node newToken:(nonnull NSString *)newToken)
|
|
37
38
|
|
|
38
39
|
@end
|
|
@@ -14,6 +14,11 @@ export function removeDownloadProgressListener() {
|
|
|
14
14
|
export function onDownloadProgressChanged(listener) {
|
|
15
15
|
return downloadEventEmitter.addListener('onDownloadProgressChanged', listener);
|
|
16
16
|
}
|
|
17
|
+
export function onDownloadStateChanged(listener) {
|
|
18
|
+
return downloadEventEmitter.addListener('onDownloadStateChanged', event => {
|
|
19
|
+
listener(event.downloadItem, event.error);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
17
22
|
export function pauseDownload(videoId) {
|
|
18
23
|
return TPStreamsDownload.pauseDownload(videoId);
|
|
19
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","TPStreamsDownload","downloadEventEmitter","addDownloadProgressListener","removeDownloadProgressListener","onDownloadProgressChanged","listener","addListener","pauseDownload","videoId","resumeDownload","removeDownload","isDownloaded","isDownloading","isPaused","getDownloadStatus","getAllDownloads"],"sourceRoot":"../../src","sources":["TPStreamsDownload.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,cAAc;AAGhE,MAAM;EAAEC;AAAkB,CAAC,GAAGF,aAAa;
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","TPStreamsDownload","downloadEventEmitter","addDownloadProgressListener","removeDownloadProgressListener","onDownloadProgressChanged","listener","addListener","onDownloadStateChanged","event","downloadItem","error","pauseDownload","videoId","resumeDownload","removeDownload","isDownloaded","isDownloading","isPaused","getDownloadStatus","getAllDownloads"],"sourceRoot":"../../src","sources":["TPStreamsDownload.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,cAAc;AAGhE,MAAM;EAAEC;AAAkB,CAAC,GAAGF,aAAa;AA4B3C,MAAMG,oBAAoB,GAAG,IAAIF,kBAAkB,CAACC,iBAAiB,CAAC;AAEtE,OAAO,SAASE,2BAA2BA,CAAA,EAAkB;EAC3D,OA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SAASO,eAAeA,CAAA,EAA4B;EACzD,OAAOnB,iBAAiB,CAACmB,eAAe,CAAC,CAAC;AAC5C","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export * from './TPStreamsPlayerViewNativeComponent';
|
|
|
7
7
|
|
|
8
8
|
// Export the wrapper component as TPStreamsPlayerView
|
|
9
9
|
export { default as TPStreamsPlayerView } from "./TPStreamsPlayer.js";
|
|
10
|
-
export { pauseDownload, resumeDownload, removeDownload, isDownloaded, isDownloading, isPaused, getDownloadStatus, getAllDownloads, addDownloadProgressListener, removeDownloadProgressListener, onDownloadProgressChanged } from "./TPStreamsDownload.js";
|
|
10
|
+
export { pauseDownload, resumeDownload, removeDownload, isDownloaded, isDownloading, isPaused, getDownloadStatus, getAllDownloads, addDownloadProgressListener, removeDownloadProgressListener, onDownloadProgressChanged, onDownloadStateChanged } from "./TPStreamsDownload.js";
|
|
11
11
|
const TPStreamsModule = NativeModules.TPStreams;
|
|
12
12
|
export const TPStreams = {
|
|
13
13
|
initialize: organizationId => {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","default","TPStreamsPlayerNative","TPStreamsPlayerView","pauseDownload","resumeDownload","removeDownload","isDownloaded","isDownloading","isPaused","getDownloadStatus","getAllDownloads","addDownloadProgressListener","removeDownloadProgressListener","onDownloadProgressChanged","TPStreamsModule","TPStreams","initialize","organizationId"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAC5C;AACA,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,sCAAsC;AACvF,cAAc,sCAAsC;;AAEpD;AACA,SAASD,OAAO,IAAIE,mBAAmB,QAAQ,sBAAmB;AAGlE,SACEC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,YAAY,EACZC,aAAa,EACbC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,2BAA2B,EAC3BC,8BAA8B,EAC9BC,yBAAyB,
|
|
1
|
+
{"version":3,"names":["NativeModules","default","TPStreamsPlayerNative","TPStreamsPlayerView","pauseDownload","resumeDownload","removeDownload","isDownloaded","isDownloading","isPaused","getDownloadStatus","getAllDownloads","addDownloadProgressListener","removeDownloadProgressListener","onDownloadProgressChanged","onDownloadStateChanged","TPStreamsModule","TPStreams","initialize","organizationId"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAC5C;AACA,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,sCAAsC;AACvF,cAAc,sCAAsC;;AAEpD;AACA,SAASD,OAAO,IAAIE,mBAAmB,QAAQ,sBAAmB;AAGlE,SACEC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,YAAY,EACZC,aAAa,EACbC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,2BAA2B,EAC3BC,8BAA8B,EAC9BC,yBAAyB,EACzBC,sBAAsB,QAKjB,wBAAqB;AAE5B,MAAMC,eAAe,GAAGhB,aAAa,CAACiB,SAAS;AAE/C,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAGC,cAAsB,IAAW;IAC5CH,eAAe,CAACE,UAAU,CAACC,cAAc,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -11,9 +11,15 @@ export interface DownloadItem {
|
|
|
11
11
|
}
|
|
12
12
|
export type DownloadProgressChange = DownloadItem;
|
|
13
13
|
export type DownloadProgressListener = (downloads: DownloadProgressChange[]) => void;
|
|
14
|
+
export interface DownloadError {
|
|
15
|
+
message: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}
|
|
18
|
+
export type DownloadStateChangeListener = (downloadItem: DownloadItem, error: DownloadError | null) => void;
|
|
14
19
|
export declare function addDownloadProgressListener(): Promise<void>;
|
|
15
20
|
export declare function removeDownloadProgressListener(): Promise<void>;
|
|
16
21
|
export declare function onDownloadProgressChanged(listener: DownloadProgressListener): EmitterSubscription;
|
|
22
|
+
export declare function onDownloadStateChanged(listener: DownloadStateChangeListener): EmitterSubscription;
|
|
17
23
|
export declare function pauseDownload(videoId: string): Promise<void>;
|
|
18
24
|
export declare function resumeDownload(videoId: string): Promise<void>;
|
|
19
25
|
export declare function removeDownload(videoId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TPStreamsDownload.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsDownload.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAIxD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAClD,MAAM,MAAM,wBAAwB,GAAG,CACrC,SAAS,EAAE,sBAAsB,EAAE,KAChC,IAAI,CAAC;AAIV,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,wBAAgB,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9D;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,wBAAwB,GACjC,mBAAmB,CAKrB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;AAED,wBAAgB,YAAY,CA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,CAAC,CAE9D;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,wBAAwB,GACjC,mBAAmB,CAKrB;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,2BAA2B,GACpC,mBAAmB,CAIrB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE9D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE/D;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAElE;AAED,wBAAgB,eAAe,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAEzD"}
|
|
@@ -2,7 +2,7 @@ export { default as TPStreamsPlayerNative } from './TPStreamsPlayerViewNativeCom
|
|
|
2
2
|
export * from './TPStreamsPlayerViewNativeComponent';
|
|
3
3
|
export { default as TPStreamsPlayerView } from './TPStreamsPlayer';
|
|
4
4
|
export type { TPStreamsPlayerRef } from './TPStreamsPlayer';
|
|
5
|
-
export { pauseDownload, resumeDownload, removeDownload, isDownloaded, isDownloading, isPaused, getDownloadStatus, getAllDownloads, addDownloadProgressListener, removeDownloadProgressListener, onDownloadProgressChanged, type DownloadItem, type DownloadProgressChange, type DownloadProgressListener, } from './TPStreamsDownload';
|
|
5
|
+
export { pauseDownload, resumeDownload, removeDownload, isDownloaded, isDownloading, isPaused, getDownloadStatus, getAllDownloads, addDownloadProgressListener, removeDownloadProgressListener, onDownloadProgressChanged, onDownloadStateChanged, type DownloadItem, type DownloadProgressChange, type DownloadProgressListener, type DownloadStateChangeListener, } from './TPStreamsDownload';
|
|
6
6
|
export declare const TPStreams: {
|
|
7
7
|
initialize: (organizationId: string) => void;
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACxF,cAAc,sCAAsC,CAAC;AAGrD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACxF,cAAc,sCAAsC,CAAC;AAGrD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,GACjC,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,SAAS;iCACS,MAAM,KAAG,IAAI;CAG3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -19,6 +19,16 @@ export type DownloadProgressListener = (
|
|
|
19
19
|
downloads: DownloadProgressChange[]
|
|
20
20
|
) => void;
|
|
21
21
|
|
|
22
|
+
export interface DownloadError {
|
|
23
|
+
message: string;
|
|
24
|
+
type: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type DownloadStateChangeListener = (
|
|
28
|
+
downloadItem: DownloadItem,
|
|
29
|
+
error: DownloadError | null
|
|
30
|
+
) => void;
|
|
31
|
+
|
|
22
32
|
const downloadEventEmitter = new NativeEventEmitter(TPStreamsDownload);
|
|
23
33
|
|
|
24
34
|
export function addDownloadProgressListener(): Promise<void> {
|
|
@@ -38,6 +48,14 @@ export function onDownloadProgressChanged(
|
|
|
38
48
|
);
|
|
39
49
|
}
|
|
40
50
|
|
|
51
|
+
export function onDownloadStateChanged(
|
|
52
|
+
listener: DownloadStateChangeListener
|
|
53
|
+
): EmitterSubscription {
|
|
54
|
+
return downloadEventEmitter.addListener('onDownloadStateChanged', (event) => {
|
|
55
|
+
listener(event.downloadItem, event.error);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
41
59
|
export function pauseDownload(videoId: string): Promise<void> {
|
|
42
60
|
return TPStreamsDownload.pauseDownload(videoId);
|
|
43
61
|
}
|
package/src/index.tsx
CHANGED
|
@@ -19,9 +19,11 @@ export {
|
|
|
19
19
|
addDownloadProgressListener,
|
|
20
20
|
removeDownloadProgressListener,
|
|
21
21
|
onDownloadProgressChanged,
|
|
22
|
+
onDownloadStateChanged,
|
|
22
23
|
type DownloadItem,
|
|
23
24
|
type DownloadProgressChange,
|
|
24
25
|
type DownloadProgressListener,
|
|
26
|
+
type DownloadStateChangeListener,
|
|
25
27
|
} from './TPStreamsDownload';
|
|
26
28
|
|
|
27
29
|
const TPStreamsModule = NativeModules.TPStreams;
|