react-native-tpstreams 0.2.9 → 0.2.12
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/README.md +152 -3
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt +128 -0
- package/android/src/main/java/com/tpstreams/TPStreamsRNPackage.kt +1 -0
- package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerView.kt +30 -4
- package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerViewManager.kt +25 -0
- package/lib/module/TPStreamsDownload.js +31 -0
- package/lib/module/TPStreamsDownload.js.map +1 -0
- package/lib/module/TPStreamsPlayer.js +8 -0
- package/lib/module/TPStreamsPlayer.js.map +1 -1
- package/lib/module/TPStreamsPlayerViewNativeComponent.ts +4 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/TPStreamsDownload.d.ts +18 -0
- package/lib/typescript/src/TPStreamsDownload.d.ts.map +1 -0
- package/lib/typescript/src/TPStreamsPlayer.d.ts +4 -0
- package/lib/typescript/src/TPStreamsPlayer.d.ts.map +1 -1
- package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TPStreamsDownload.tsx +45 -0
- package/src/TPStreamsPlayer.tsx +12 -0
- package/src/TPStreamsPlayerViewNativeComponent.ts +4 -0
- package/src/index.tsx +12 -0
package/README.md
CHANGED
|
@@ -77,6 +77,54 @@ import { TPStreamsPlayerView } from "react-native-tpstreams";
|
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
+
## Player Props
|
|
81
|
+
|
|
82
|
+
- `videoId`: (Required) The ID of the video to play.
|
|
83
|
+
|
|
84
|
+
- `accessToken`: (Required) Access token for the video.
|
|
85
|
+
|
|
86
|
+
- `startAt`: (Optional) Position in seconds where playback should start. Default is 0.
|
|
87
|
+
|
|
88
|
+
- `shouldAutoPlay`: (Optional) Whether the video should start playing automatically. Default is true.
|
|
89
|
+
|
|
90
|
+
- `showDefaultCaptions`: (Optional) Whether to show default captions if available. Default is false.
|
|
91
|
+
|
|
92
|
+
- `enableDownload`: (Optional) Whether to enable download functionality for the video. When set to true, the player will show a download button. Default is false.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Downloads
|
|
97
|
+
|
|
98
|
+
### Download Methods
|
|
99
|
+
|
|
100
|
+
- `pauseDownload(videoId: string)`: Pauses an ongoing download. Returns `Promise<void>`.
|
|
101
|
+
|
|
102
|
+
- `resumeDownload(videoId: string)`: Resumes a paused download. Returns `Promise<void>`.
|
|
103
|
+
|
|
104
|
+
- `removeDownload(videoId: string)`: Removes a downloaded video. Returns `Promise<void>`.
|
|
105
|
+
|
|
106
|
+
- `isDownloaded(videoId: string)`: Checks if a video has been downloaded. Returns `Promise<boolean>`.
|
|
107
|
+
|
|
108
|
+
- `isDownloading(videoId: string)`: Checks if a video is currently downloading. Returns `Promise<boolean>`.
|
|
109
|
+
|
|
110
|
+
- `isPaused(videoId: string)`: Checks if a video download is paused. Returns `Promise<boolean>`.
|
|
111
|
+
|
|
112
|
+
- `getDownloadStatus(videoId: string)`: Gets the download status of a video as a descriptive string. Returns `Promise<string>`.
|
|
113
|
+
|
|
114
|
+
- `getAllDownloads()`: Gets all downloaded videos. Returns `Promise<DownloadItem[]>`.
|
|
115
|
+
|
|
116
|
+
### Download Item
|
|
117
|
+
|
|
118
|
+
The download item object (`DownloadItem`) contains information about a downloaded or downloading video, including:
|
|
119
|
+
|
|
120
|
+
- `assetId`: The ID of the video.
|
|
121
|
+
- `state`: The current state of the download as String (Queued, Downloading, Completed, Failed, Removing, Restarting, Paused ).
|
|
122
|
+
- `progressPercentage`: Download progress from 0 to 100.
|
|
123
|
+
- `title`: The title of the video Asset.
|
|
124
|
+
- `thumbnailUrl`: URL to the video thumbnail (if available).
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
80
128
|
## Example
|
|
81
129
|
|
|
82
130
|
```js
|
|
@@ -116,6 +164,10 @@ function TPStreamsPlayerExample() {
|
|
|
116
164
|
videoId="YOUR_VIDEO_ID"
|
|
117
165
|
accessToken="YOUR_ACCESS_TOKEN"
|
|
118
166
|
style={{ height: 250 }}
|
|
167
|
+
startAt={100}
|
|
168
|
+
shouldAutoPlay={false}
|
|
169
|
+
showDefaultCaptions={true}
|
|
170
|
+
enableDownload={true}
|
|
119
171
|
onPlayerStateChanged={(state) => console.log(`Player state: ${state}`)}
|
|
120
172
|
onIsPlayingChanged={(isPlaying) => console.log(`Is playing: ${isPlaying}`)}
|
|
121
173
|
onPlaybackSpeedChanged={(speed) => console.log(`Speed changed: ${speed}x`)}
|
|
@@ -135,12 +187,109 @@ function TPStreamsPlayerExample() {
|
|
|
135
187
|
|
|
136
188
|
---
|
|
137
189
|
|
|
190
|
+
## Download Example
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
import {
|
|
194
|
+
pauseDownload,
|
|
195
|
+
resumeDownload,
|
|
196
|
+
removeDownload,
|
|
197
|
+
getAllDownloads,
|
|
198
|
+
getDownloadStatus,
|
|
199
|
+
isDownloaded,
|
|
200
|
+
isDownloading,
|
|
201
|
+
type DownloadItem,
|
|
202
|
+
} from 'react-native-tpstreams';
|
|
203
|
+
|
|
204
|
+
// Get all downloads
|
|
205
|
+
const loadDownloads = async () => {
|
|
206
|
+
try {
|
|
207
|
+
const items: DownloadItem[] = await getAllDownloads();
|
|
208
|
+
console.log(`Found ${items.length} downloads`);
|
|
209
|
+
return items;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
console.error('Failed to load downloads:', error);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// Check download status
|
|
216
|
+
const checkStatus = async (videoId: string) => {
|
|
217
|
+
try {
|
|
218
|
+
const status = await getDownloadStatus(videoId);
|
|
219
|
+
console.log(`Status: ${status}`);
|
|
220
|
+
return status;
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error('Error checking status:', error);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// Check if video is downloaded
|
|
227
|
+
const checkIfDownloaded = async (videoId: string) => {
|
|
228
|
+
try {
|
|
229
|
+
const downloaded: boolean = await isDownloaded(videoId);
|
|
230
|
+
console.log(`Is downloaded: ${downloaded}`);
|
|
231
|
+
return downloaded;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error('Error checking if downloaded:', error);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// Check if video is currently downloading
|
|
238
|
+
const checkIfDownloading = async (videoId: string) => {
|
|
239
|
+
try {
|
|
240
|
+
const downloading: boolean = await isDownloading(videoId);
|
|
241
|
+
console.log(`Is downloading: ${downloading}`);
|
|
242
|
+
return downloading;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error('Error checking if downloading:', error);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// Pause a download
|
|
249
|
+
const pauseVideoDownload = async (videoId: string) => {
|
|
250
|
+
try {
|
|
251
|
+
await pauseDownload(videoId);
|
|
252
|
+
console.log('Download paused successfully');
|
|
253
|
+
|
|
254
|
+
// Check status after pausing
|
|
255
|
+
const status = await getDownloadStatus(videoId);
|
|
256
|
+
console.log(`New status: ${status}`);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error('Error pausing download:', error);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Resume a download
|
|
263
|
+
const resumeVideoDownload = async (videoId: string) => {
|
|
264
|
+
try {
|
|
265
|
+
await resumeDownload(videoId);
|
|
266
|
+
console.log('Download resumed');
|
|
267
|
+
|
|
268
|
+
// Check status after resuming
|
|
269
|
+
const status = await getDownloadStatus(videoId);
|
|
270
|
+
console.log(`New status: ${status}`);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.error('Error resuming download:', error);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// Remove a download
|
|
277
|
+
const removeVideoDownload = async (videoId: string) => {
|
|
278
|
+
try {
|
|
279
|
+
await removeDownload(videoId);
|
|
280
|
+
console.log('Download removed');
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error('Error removing download:', error);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
138
289
|
## Contributing
|
|
139
290
|
|
|
140
291
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
141
292
|
|
|
142
293
|
## License
|
|
143
294
|
|
|
144
|
-
MIT
|
|
145
|
-
|
|
146
|
-
---
|
|
295
|
+
MIT
|
package/android/build.gradle
CHANGED
|
@@ -82,7 +82,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
82
82
|
dependencies {
|
|
83
83
|
implementation "com.facebook.react:react-android"
|
|
84
84
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
85
|
-
implementation 'com.github.testpress:TPStreamsAndroidPlayer:1.0.
|
|
85
|
+
implementation 'com.github.testpress:TPStreamsAndroidPlayer:1.0.6'
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
react {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
package com.tpstreams
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
9
|
+
import com.tpstreams.player.download.DownloadClient
|
|
10
|
+
import com.tpstreams.player.download.DownloadItem
|
|
11
|
+
|
|
12
|
+
class TPStreamsDownloadModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
13
|
+
|
|
14
|
+
private val downloadClient: DownloadClient by lazy {
|
|
15
|
+
DownloadClient.getInstance(reactContext)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun getName(): String {
|
|
19
|
+
return "TPStreamsDownload"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@ReactMethod
|
|
23
|
+
fun pauseDownload(videoId: String, promise: Promise) {
|
|
24
|
+
try {
|
|
25
|
+
downloadClient.pauseDownload(videoId)
|
|
26
|
+
promise.resolve(null)
|
|
27
|
+
} catch (e: Exception) {
|
|
28
|
+
Log.e(TAG, "Error pausing download: ${e.message}", e)
|
|
29
|
+
promise.reject("DOWNLOAD_PAUSE_ERROR", e.message, e)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@ReactMethod
|
|
34
|
+
fun resumeDownload(videoId: String, promise: Promise) {
|
|
35
|
+
try {
|
|
36
|
+
downloadClient.resumeDownload(videoId)
|
|
37
|
+
promise.resolve(null)
|
|
38
|
+
} catch (e: Exception) {
|
|
39
|
+
Log.e(TAG, "Error resuming download: ${e.message}", e)
|
|
40
|
+
promise.reject("DOWNLOAD_RESUME_ERROR", e.message, e)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
fun removeDownload(videoId: String, promise: Promise) {
|
|
46
|
+
try {
|
|
47
|
+
downloadClient.removeDownload(videoId)
|
|
48
|
+
promise.resolve(null)
|
|
49
|
+
} catch (e: Exception) {
|
|
50
|
+
Log.e(TAG, "Error removing download: ${e.message}", e)
|
|
51
|
+
promise.reject("DOWNLOAD_REMOVE_ERROR", e.message, e)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
fun isDownloaded(videoId: String, promise: Promise) {
|
|
57
|
+
try {
|
|
58
|
+
val isDownloaded = downloadClient.isDownloaded(videoId)
|
|
59
|
+
promise.resolve(isDownloaded)
|
|
60
|
+
} catch (e: Exception) {
|
|
61
|
+
Log.e(TAG, "Error checking if downloaded: ${e.message}", e)
|
|
62
|
+
promise.reject("DOWNLOAD_CHECK_ERROR", e.message, e)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@ReactMethod
|
|
67
|
+
fun isDownloading(videoId: String, promise: Promise) {
|
|
68
|
+
try {
|
|
69
|
+
val isDownloading = downloadClient.isDownloading(videoId)
|
|
70
|
+
promise.resolve(isDownloading)
|
|
71
|
+
} catch (e: Exception) {
|
|
72
|
+
Log.e(TAG, "Error checking if downloading: ${e.message}", e)
|
|
73
|
+
promise.reject("DOWNLOAD_CHECK_ERROR", e.message, e)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@ReactMethod
|
|
78
|
+
fun isPaused(videoId: String, promise: Promise) {
|
|
79
|
+
try {
|
|
80
|
+
val isPaused = downloadClient.isPaused(videoId)
|
|
81
|
+
promise.resolve(isPaused)
|
|
82
|
+
} catch (e: Exception) {
|
|
83
|
+
Log.e(TAG, "Error checking if paused: ${e.message}", e)
|
|
84
|
+
promise.reject("DOWNLOAD_CHECK_ERROR", e.message, e)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@ReactMethod
|
|
89
|
+
fun getDownloadStatus(videoId: String, promise: Promise) {
|
|
90
|
+
try {
|
|
91
|
+
val status = downloadClient.getDownloadStatus(videoId)
|
|
92
|
+
promise.resolve(status)
|
|
93
|
+
} catch (e: Exception) {
|
|
94
|
+
Log.e(TAG, "Error getting download status: ${e.message}", e)
|
|
95
|
+
promise.reject("DOWNLOAD_STATUS_ERROR", e.message, e)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@ReactMethod
|
|
100
|
+
fun getAllDownloads(promise: Promise) {
|
|
101
|
+
try {
|
|
102
|
+
val downloadItems = downloadClient.getAllDownloadItems()
|
|
103
|
+
val result = Arguments.createArray()
|
|
104
|
+
|
|
105
|
+
for (item in downloadItems) {
|
|
106
|
+
val map = Arguments.createMap()
|
|
107
|
+
map.putString("videoId", item.assetId)
|
|
108
|
+
map.putString("title", item.title)
|
|
109
|
+
item.thumbnailUrl?.let { map.putString("thumbnailUrl", it) }
|
|
110
|
+
map.putDouble("totalBytes", item.totalBytes.toDouble())
|
|
111
|
+
map.putDouble("downloadedBytes", item.downloadedBytes.toDouble())
|
|
112
|
+
map.putDouble("progressPercentage", item.progressPercentage.toDouble())
|
|
113
|
+
map.putString("state", downloadClient.getDownloadStatus(item.assetId))
|
|
114
|
+
|
|
115
|
+
result.pushMap(map)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
promise.resolve(result)
|
|
119
|
+
} catch (e: Exception) {
|
|
120
|
+
Log.e(TAG, "Error getting all download items: ${e.message}", e)
|
|
121
|
+
promise.reject("DOWNLOAD_ITEMS_ERROR", e.message, e)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
companion object {
|
|
126
|
+
private const val TAG = "TPStreamsDownloadModule"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -16,6 +16,7 @@ class TPStreamsRNPackage : ReactPackage {
|
|
|
16
16
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
17
17
|
val modules: MutableList<NativeModule> = ArrayList()
|
|
18
18
|
modules.add(TPStreamsRNModule(reactContext))
|
|
19
|
+
modules.add(TPStreamsDownloadModule(reactContext))
|
|
19
20
|
return modules
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -19,6 +19,10 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
19
19
|
|
|
20
20
|
private var videoId: String? = null
|
|
21
21
|
private var accessToken: String? = null
|
|
22
|
+
private var shouldAutoPlay: Boolean = true
|
|
23
|
+
private var startAt: Long = 0
|
|
24
|
+
private var showDefaultCaptions: Boolean = false
|
|
25
|
+
private var enableDownload: Boolean = false
|
|
22
26
|
|
|
23
27
|
init {
|
|
24
28
|
addView(playerView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
@@ -51,20 +55,42 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
51
55
|
|
|
52
56
|
fun setVideoId(videoId: String?) {
|
|
53
57
|
this.videoId = videoId
|
|
54
|
-
tryCreatePlayer()
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
fun setAccessToken(accessToken: String?) {
|
|
58
61
|
this.accessToken = accessToken
|
|
59
|
-
tryCreatePlayer()
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
fun setShouldAutoPlay(shouldAutoPlay: Boolean) {
|
|
65
|
+
this.shouldAutoPlay = shouldAutoPlay
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fun setStartAt(startAt: Long) {
|
|
69
|
+
this.startAt = startAt
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fun setShowDefaultCaptions(showDefaultCaptions: Boolean) {
|
|
73
|
+
this.showDefaultCaptions = showDefaultCaptions
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fun setEnableDownload(enableDownload: Boolean) {
|
|
77
|
+
this.enableDownload = enableDownload
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fun tryCreatePlayer() {
|
|
63
81
|
if (videoId.isNullOrEmpty() || accessToken.isNullOrEmpty()) return
|
|
64
82
|
if (player != null) return
|
|
65
83
|
|
|
66
84
|
try {
|
|
67
|
-
player = TPStreamsPlayer.create(
|
|
85
|
+
player = TPStreamsPlayer.create(
|
|
86
|
+
context,
|
|
87
|
+
videoId!!,
|
|
88
|
+
accessToken!!,
|
|
89
|
+
shouldAutoPlay,
|
|
90
|
+
startAt,
|
|
91
|
+
enableDownload,
|
|
92
|
+
showDefaultCaptions
|
|
93
|
+
)
|
|
68
94
|
|
|
69
95
|
// Add player event listeners
|
|
70
96
|
player?.addListener(createPlayerListener())
|
|
@@ -62,6 +62,26 @@ class TPStreamsRNPlayerViewManager : SimpleViewManager<TPStreamsRNPlayerView>(),
|
|
|
62
62
|
view.setAccessToken(accessToken)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
@ReactProp(name = "shouldAutoPlay")
|
|
66
|
+
override fun setShouldAutoPlay(view: TPStreamsRNPlayerView, shouldAutoPlay: Boolean) {
|
|
67
|
+
view.setShouldAutoPlay(shouldAutoPlay)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@ReactProp(name = "startAt")
|
|
71
|
+
override fun setStartAt(view: TPStreamsRNPlayerView, startAt: Double) {
|
|
72
|
+
view.setStartAt(startAt.toLong())
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactProp(name = "showDefaultCaptions")
|
|
76
|
+
override fun setShowDefaultCaptions(view: TPStreamsRNPlayerView, showDefaultCaptions: Boolean) {
|
|
77
|
+
view.setShowDefaultCaptions(showDefaultCaptions)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@ReactProp(name = "enableDownload")
|
|
81
|
+
override fun setEnableDownload(view: TPStreamsRNPlayerView, enableDownload: Boolean) {
|
|
82
|
+
view.setEnableDownload(enableDownload)
|
|
83
|
+
}
|
|
84
|
+
|
|
65
85
|
// Command implementations
|
|
66
86
|
override fun play(view: TPStreamsRNPlayerView) {
|
|
67
87
|
view.play()
|
|
@@ -94,4 +114,9 @@ class TPStreamsRNPlayerViewManager : SimpleViewManager<TPStreamsRNPlayerView>(),
|
|
|
94
114
|
override fun getPlaybackSpeed(view: TPStreamsRNPlayerView) {
|
|
95
115
|
view.getPlaybackSpeed()
|
|
96
116
|
}
|
|
117
|
+
|
|
118
|
+
override fun onAfterUpdateTransaction(view: TPStreamsRNPlayerView) {
|
|
119
|
+
super.onAfterUpdateTransaction(view)
|
|
120
|
+
view.tryCreatePlayer()
|
|
121
|
+
}
|
|
97
122
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules } from 'react-native';
|
|
4
|
+
const {
|
|
5
|
+
TPStreamsDownload
|
|
6
|
+
} = NativeModules;
|
|
7
|
+
export function pauseDownload(videoId) {
|
|
8
|
+
return TPStreamsDownload.pauseDownload(videoId);
|
|
9
|
+
}
|
|
10
|
+
export function resumeDownload(videoId) {
|
|
11
|
+
return TPStreamsDownload.resumeDownload(videoId);
|
|
12
|
+
}
|
|
13
|
+
export function removeDownload(videoId) {
|
|
14
|
+
return TPStreamsDownload.removeDownload(videoId);
|
|
15
|
+
}
|
|
16
|
+
export function isDownloaded(videoId) {
|
|
17
|
+
return TPStreamsDownload.isDownloaded(videoId);
|
|
18
|
+
}
|
|
19
|
+
export function isDownloading(videoId) {
|
|
20
|
+
return TPStreamsDownload.isDownloading(videoId);
|
|
21
|
+
}
|
|
22
|
+
export function isPaused(videoId) {
|
|
23
|
+
return TPStreamsDownload.isPaused(videoId);
|
|
24
|
+
}
|
|
25
|
+
export function getDownloadStatus(videoId) {
|
|
26
|
+
return TPStreamsDownload.getDownloadStatus(videoId);
|
|
27
|
+
}
|
|
28
|
+
export function getAllDownloads() {
|
|
29
|
+
return TPStreamsDownload.getAllDownloads();
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=TPStreamsDownload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","TPStreamsDownload","pauseDownload","videoId","resumeDownload","removeDownload","isDownloaded","isDownloading","isPaused","getDownloadStatus","getAllDownloads"],"sourceRoot":"../../src","sources":["TPStreamsDownload.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAE5C,MAAM;EAAEC;AAAkB,CAAC,GAAGD,aAAa;AAY3C,OAAO,SAASE,aAAaA,CAACC,OAAe,EAAiB;EAC5D,OAAOF,iBAAiB,CAACC,aAAa,CAACC,OAAO,CAAC;AACjD;AAEA,OAAO,SAASC,cAAcA,CAACD,OAAe,EAAiB;EAC7D,OAAOF,iBAAiB,CAACG,cAAc,CAACD,OAAO,CAAC;AAClD;AAEA,OAAO,SAASE,cAAcA,CAACF,OAAe,EAAiB;EAC7D,OAAOF,iBAAiB,CAACI,cAAc,CAACF,OAAO,CAAC;AAClD;AAEA,OAAO,SAASG,YAAYA,CAACH,OAAe,EAAoB;EAC9D,OAAOF,iBAAiB,CAACK,YAAY,CAACH,OAAO,CAAC;AAChD;AAEA,OAAO,SAASI,aAAaA,CAACJ,OAAe,EAAoB;EAC/D,OAAOF,iBAAiB,CAACM,aAAa,CAACJ,OAAO,CAAC;AACjD;AAEA,OAAO,SAASK,QAAQA,CAACL,OAAe,EAAoB;EAC1D,OAAOF,iBAAiB,CAACO,QAAQ,CAACL,OAAO,CAAC;AAC5C;AAEA,OAAO,SAASM,iBAAiBA,CAACN,OAAe,EAAmB;EAClE,OAAOF,iBAAiB,CAACQ,iBAAiB,CAACN,OAAO,CAAC;AACrD;AAEA,OAAO,SAASO,eAAeA,CAAA,EAA4B;EACzD,OAAOT,iBAAiB,CAACS,eAAe,CAAC,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -20,6 +20,10 @@ const TPStreamsPlayerView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
20
20
|
const {
|
|
21
21
|
videoId,
|
|
22
22
|
accessToken,
|
|
23
|
+
shouldAutoPlay,
|
|
24
|
+
startAt,
|
|
25
|
+
enableDownload,
|
|
26
|
+
showDefaultCaptions,
|
|
23
27
|
style,
|
|
24
28
|
onPlayerStateChanged,
|
|
25
29
|
onIsPlayingChanged,
|
|
@@ -139,6 +143,10 @@ const TPStreamsPlayerView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
139
143
|
...restProps,
|
|
140
144
|
videoId,
|
|
141
145
|
accessToken,
|
|
146
|
+
shouldAutoPlay,
|
|
147
|
+
startAt,
|
|
148
|
+
enableDownload,
|
|
149
|
+
showDefaultCaptions,
|
|
142
150
|
style,
|
|
143
151
|
onCurrentPosition,
|
|
144
152
|
onDuration,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useImperativeHandle","useRef","useCallback","TPStreamsPlayerNative","Commands","jsx","_jsx","nextInstanceId","TPStreamsPlayerView","props","ref","videoId","accessToken","style","onPlayerStateChanged","onIsPlayingChanged","onPlaybackSpeedChanged","onIsLoadingChanged","onError","restProps","nativeRef","instanceId","promiseMap","onCurrentPosition","event","key","current","handler","resolve","nativeEvent","position","onDuration","duration","onIsPlaying","isPlaying","onPlaybackSpeed","speed","handlePlayerStateChanged","playbackState","handleIsPlayingChanged","handlePlaybackSpeedChanged","handleIsLoadingChanged","isLoading","handleError","message","code","details","Object","entries","forEach","reject","Error","createPromiseMethod","command","eventKey","Promise","setTimeout","play","pause","seekTo","positionMs","setPlaybackSpeed","getCurrentPosition","getDuration","getPlaybackSpeed","nativeProps"],"sourceRoot":"../../src","sources":["TPStreamsPlayer.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,WAAW,QAAQ,OAAO;AAC5E,OAAOC,qBAAqB,IAC1BC,QAAQ,QACH,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO9C;AACA,IAAIC,cAAc,GAAG,CAAC;;AAEtB;;AAQA;;AAYA;;
|
|
1
|
+
{"version":3,"names":["forwardRef","useImperativeHandle","useRef","useCallback","TPStreamsPlayerNative","Commands","jsx","_jsx","nextInstanceId","TPStreamsPlayerView","props","ref","videoId","accessToken","shouldAutoPlay","startAt","enableDownload","showDefaultCaptions","style","onPlayerStateChanged","onIsPlayingChanged","onPlaybackSpeedChanged","onIsLoadingChanged","onError","restProps","nativeRef","instanceId","promiseMap","onCurrentPosition","event","key","current","handler","resolve","nativeEvent","position","onDuration","duration","onIsPlaying","isPlaying","onPlaybackSpeed","speed","handlePlayerStateChanged","playbackState","handleIsPlayingChanged","handlePlaybackSpeedChanged","handleIsLoadingChanged","isLoading","handleError","message","code","details","Object","entries","forEach","reject","Error","createPromiseMethod","command","eventKey","Promise","setTimeout","play","pause","seekTo","positionMs","setPlaybackSpeed","getCurrentPosition","getDuration","getPlaybackSpeed","nativeProps"],"sourceRoot":"../../src","sources":["TPStreamsPlayer.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,mBAAmB,EAAEC,MAAM,EAAEC,WAAW,QAAQ,OAAO;AAC5E,OAAOC,qBAAqB,IAC1BC,QAAQ,QACH,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO9C;AACA,IAAIC,cAAc,GAAG,CAAC;;AAEtB;;AAQA;;AAYA;;AAmBA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,gBAAGT,UAAU,CAGpC,CAACU,KAAK,EAAEC,GAAG,KAAK;EAChB,MAAM;IACJC,OAAO;IACPC,WAAW;IACXC,cAAc;IACdC,OAAO;IACPC,cAAc;IACdC,mBAAmB;IACnBC,KAAK;IACLC,oBAAoB;IACpBC,kBAAkB;IAClBC,sBAAsB;IACtBC,kBAAkB;IAClBC,OAAO;IACP,GAAGC;EACL,CAAC,GAAGd,KAAK;EAET,MAAMe,SAAS,GAAGvB,MAAM,CAAC,IAAI,CAAC;EAC9B,MAAMwB,UAAU,GAAGxB,MAAM,CAASM,cAAc,EAAE,CAAC;EACnD,MAAMmB,UAAU,GAAGzB,MAAM,CAAa,CAAC,CAAC,CAAC;;EAEzC;EACA,MAAM0B,iBAAiB,GAAGzB,WAAW,CAAE0B,KAAU,IAAK;IACpD,MAAMC,GAAG,GAAG,YAAYJ,UAAU,CAACK,OAAO,EAAE;IAC5C,MAAMC,OAAO,GAAGL,UAAU,CAACI,OAAO,CAACD,GAAG,CAAC;IACvC,IAAIE,OAAO,EAAE;MACXA,OAAO,CAACC,OAAO,CAACJ,KAAK,CAACK,WAAW,CAACC,QAAQ,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kB,EAAEV,mBAAmB,CACrCpD,QAAQ,CAAC8D,kBAAkB,EAC3B,UACF,CAAC;IACDC,WAAW,EAAEX,mBAAmB,CAACpD,QAAQ,CAAC+D,WAAW,EAAE,UAAU,CAAC;IAClE7B,SAAS,EAAEkB,mBAAmB,CAACpD,QAAQ,CAACkC,SAAS,EAAE,WAAW,CAAC;IAC/D8B,gBAAgB,EAAEZ,mBAAmB,CAACpD,QAAQ,CAACgE,gBAAgB,EAAE,OAAO;EAC1E,CAAC,CAAC,EACF,CAACZ,mBAAmB,CACtB,CAAC;;EAED;EACA,MAAMa,WAAwB,GAAG;IAC/B,GAAG9C,SAAS;IACZZ,OAAO;IACPC,WAAW;IACXC,cAAc;IACdC,OAAO;IACPC,cAAc;IACdC,mBAAmB;IACnBC,KAAK;IACLU,iBAAiB;IACjBQ,UAAU;IACVE,WAAW;IACXE,eAAe;IACfrB,oBAAoB,EAAEuB,wBAAwB;IAC9CtB,kBAAkB,EAAEwB,sBAAsB;IAC1CvB,sBAAsB,EAAEwB,0BAA0B;IAClDvB,kBAAkB,EAAEwB,sBAAsB;IAC1CvB,OAAO,EAAEyB;EACX,CAAC;EAED,oBAAOzC,IAAA,CAACH,qBAAqB;IAAA,GAAKkE,WAAW;IAAE3D,GAAG,EAAEc;EAAU,CAAE,CAAC;AACnE,CAAC,CAAC;AAEF,eAAehB,mBAAmB","ignoreList":[]}
|
|
@@ -18,6 +18,10 @@ export interface ErrorEvent {
|
|
|
18
18
|
export interface NativeProps extends ViewProps {
|
|
19
19
|
videoId?: string;
|
|
20
20
|
accessToken?: string;
|
|
21
|
+
shouldAutoPlay?: boolean;
|
|
22
|
+
startAt?: Double;
|
|
23
|
+
enableDownload?: boolean;
|
|
24
|
+
showDefaultCaptions?: boolean;
|
|
21
25
|
|
|
22
26
|
// Event props for receiving data from native methods
|
|
23
27
|
onCurrentPosition?: DirectEventHandler<{ position: Double }>;
|
package/lib/module/index.js
CHANGED
|
@@ -7,6 +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 } from "./TPStreamsDownload.js";
|
|
10
11
|
const TPStreamsModule = NativeModules.TPStreams;
|
|
11
12
|
export const TPStreams = {
|
|
12
13
|
initialize: organizationId => {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","default","TPStreamsPlayerNative","TPStreamsPlayerView","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,MAAMC,eAAe,
|
|
1
|
+
{"version":3,"names":["NativeModules","default","TPStreamsPlayerNative","TPStreamsPlayerView","pauseDownload","resumeDownload","removeDownload","isDownloaded","isDownloading","isPaused","getDownloadStatus","getAllDownloads","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,QAEV,wBAAqB;AAE5B,MAAMC,eAAe,GAAGZ,aAAa,CAACa,SAAS;AAE/C,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAGC,cAAsB,IAAW;IAC5CH,eAAe,CAACE,UAAU,CAACC,cAAc,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface DownloadItem {
|
|
2
|
+
videoId: string;
|
|
3
|
+
title: string;
|
|
4
|
+
thumbnailUrl?: string;
|
|
5
|
+
totalBytes: number;
|
|
6
|
+
downloadedBytes: number;
|
|
7
|
+
progressPercentage: number;
|
|
8
|
+
state: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function pauseDownload(videoId: string): Promise<void>;
|
|
11
|
+
export declare function resumeDownload(videoId: string): Promise<void>;
|
|
12
|
+
export declare function removeDownload(videoId: string): Promise<void>;
|
|
13
|
+
export declare function isDownloaded(videoId: string): Promise<boolean>;
|
|
14
|
+
export declare function isDownloading(videoId: string): Promise<boolean>;
|
|
15
|
+
export declare function isPaused(videoId: string): Promise<boolean>;
|
|
16
|
+
export declare function getDownloadStatus(videoId: string): Promise<string>;
|
|
17
|
+
export declare function getAllDownloads(): Promise<DownloadItem[]>;
|
|
18
|
+
//# sourceMappingURL=TPStreamsDownload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TPStreamsDownload.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsDownload.tsx"],"names":[],"mappings":"AAIA,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;CACf;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"}
|
|
@@ -13,6 +13,10 @@ export interface TPStreamsPlayerRef {
|
|
|
13
13
|
export interface TPStreamsPlayerProps extends ViewProps {
|
|
14
14
|
videoId?: string;
|
|
15
15
|
accessToken?: string;
|
|
16
|
+
shouldAutoPlay?: boolean;
|
|
17
|
+
startAt?: number;
|
|
18
|
+
enableDownload?: boolean;
|
|
19
|
+
showDefaultCaptions?: boolean;
|
|
16
20
|
onPlayerStateChanged?: (state: number) => void;
|
|
17
21
|
onIsPlayingChanged?: (isPlaying: boolean) => void;
|
|
18
22
|
onPlaybackSpeedChanged?: (speed: number) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TPStreamsPlayer.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsPlayer.tsx"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAc9C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,gBAAgB,EAAE,CAAC,KAAK,EA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,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,gBAAgB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC;AAGD,MAAM,WAAW,oBAAqB,SAAQ,SAAS;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAK,IAAI,CAAC;CACZ;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,qHA8KvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
|
@@ -12,6 +12,10 @@ export interface ErrorEvent {
|
|
|
12
12
|
export interface NativeProps extends ViewProps {
|
|
13
13
|
videoId?: string;
|
|
14
14
|
accessToken?: string;
|
|
15
|
+
shouldAutoPlay?: boolean;
|
|
16
|
+
startAt?: Double;
|
|
17
|
+
enableDownload?: boolean;
|
|
18
|
+
showDefaultCaptions?: boolean;
|
|
15
19
|
onCurrentPosition?: DirectEventHandler<{
|
|
16
20
|
position: Double;
|
|
17
21
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TPStreamsPlayerViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsPlayerViewNativeComponent.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACN,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"TPStreamsPlayerViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsPlayerViewNativeComponent.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACN,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,O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AM,EAAE,CACN,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,EACrD,UAAU,EAAE,MAAM,KACf,IAAI,CAAC;IACV,gBAAgB,EAAE,CAChB,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,EACrD,KAAK,EAAE,KAAK,KACT,IAAI,CAAC;IACV,kBAAkB,EAAE,CAClB,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAClD,IAAI,CAAC;IACV,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7E,SAAS,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3E,gBAAgB,EAAE,CAChB,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,KAClD,IAAI,CAAC;CACX;AAED,eAAO,MAAM,QAAQ,6BAWnB,CAAC;;AAEH,wBAA4E"}
|
|
@@ -2,6 +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, type DownloadItem, } from './TPStreamsDownload';
|
|
5
6
|
export declare const TPStreams: {
|
|
6
7
|
initialize: (organizationId: string) => void;
|
|
7
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;
|
|
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,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,SAAS;iCACS,MAAM,KAAG,IAAI;CAG3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const { TPStreamsDownload } = NativeModules;
|
|
4
|
+
|
|
5
|
+
export interface DownloadItem {
|
|
6
|
+
videoId: string;
|
|
7
|
+
title: string;
|
|
8
|
+
thumbnailUrl?: string;
|
|
9
|
+
totalBytes: number;
|
|
10
|
+
downloadedBytes: number;
|
|
11
|
+
progressPercentage: number;
|
|
12
|
+
state: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function pauseDownload(videoId: string): Promise<void> {
|
|
16
|
+
return TPStreamsDownload.pauseDownload(videoId);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function resumeDownload(videoId: string): Promise<void> {
|
|
20
|
+
return TPStreamsDownload.resumeDownload(videoId);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function removeDownload(videoId: string): Promise<void> {
|
|
24
|
+
return TPStreamsDownload.removeDownload(videoId);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isDownloaded(videoId: string): Promise<boolean> {
|
|
28
|
+
return TPStreamsDownload.isDownloaded(videoId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isDownloading(videoId: string): Promise<boolean> {
|
|
32
|
+
return TPStreamsDownload.isDownloading(videoId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isPaused(videoId: string): Promise<boolean> {
|
|
36
|
+
return TPStreamsDownload.isPaused(videoId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getDownloadStatus(videoId: string): Promise<string> {
|
|
40
|
+
return TPStreamsDownload.getDownloadStatus(videoId);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getAllDownloads(): Promise<DownloadItem[]> {
|
|
44
|
+
return TPStreamsDownload.getAllDownloads();
|
|
45
|
+
}
|
package/src/TPStreamsPlayer.tsx
CHANGED
|
@@ -35,6 +35,10 @@ export interface TPStreamsPlayerRef {
|
|
|
35
35
|
export interface TPStreamsPlayerProps extends ViewProps {
|
|
36
36
|
videoId?: string;
|
|
37
37
|
accessToken?: string;
|
|
38
|
+
shouldAutoPlay?: boolean;
|
|
39
|
+
startAt?: number;
|
|
40
|
+
enableDownload?: boolean;
|
|
41
|
+
showDefaultCaptions?: boolean;
|
|
38
42
|
onPlayerStateChanged?: (state: number) => void;
|
|
39
43
|
onIsPlayingChanged?: (isPlaying: boolean) => void;
|
|
40
44
|
onPlaybackSpeedChanged?: (speed: number) => void;
|
|
@@ -57,6 +61,10 @@ const TPStreamsPlayerView = forwardRef<
|
|
|
57
61
|
const {
|
|
58
62
|
videoId,
|
|
59
63
|
accessToken,
|
|
64
|
+
shouldAutoPlay,
|
|
65
|
+
startAt,
|
|
66
|
+
enableDownload,
|
|
67
|
+
showDefaultCaptions,
|
|
60
68
|
style,
|
|
61
69
|
onPlayerStateChanged,
|
|
62
70
|
onIsPlayingChanged,
|
|
@@ -203,6 +211,10 @@ const TPStreamsPlayerView = forwardRef<
|
|
|
203
211
|
...restProps,
|
|
204
212
|
videoId,
|
|
205
213
|
accessToken,
|
|
214
|
+
shouldAutoPlay,
|
|
215
|
+
startAt,
|
|
216
|
+
enableDownload,
|
|
217
|
+
showDefaultCaptions,
|
|
206
218
|
style,
|
|
207
219
|
onCurrentPosition,
|
|
208
220
|
onDuration,
|
|
@@ -18,6 +18,10 @@ export interface ErrorEvent {
|
|
|
18
18
|
export interface NativeProps extends ViewProps {
|
|
19
19
|
videoId?: string;
|
|
20
20
|
accessToken?: string;
|
|
21
|
+
shouldAutoPlay?: boolean;
|
|
22
|
+
startAt?: Double;
|
|
23
|
+
enableDownload?: boolean;
|
|
24
|
+
showDefaultCaptions?: boolean;
|
|
21
25
|
|
|
22
26
|
// Event props for receiving data from native methods
|
|
23
27
|
onCurrentPosition?: DirectEventHandler<{ position: Double }>;
|
package/src/index.tsx
CHANGED
|
@@ -7,6 +7,18 @@ export * from './TPStreamsPlayerViewNativeComponent';
|
|
|
7
7
|
export { default as TPStreamsPlayerView } from './TPStreamsPlayer';
|
|
8
8
|
export type { TPStreamsPlayerRef } from './TPStreamsPlayer';
|
|
9
9
|
|
|
10
|
+
export {
|
|
11
|
+
pauseDownload,
|
|
12
|
+
resumeDownload,
|
|
13
|
+
removeDownload,
|
|
14
|
+
isDownloaded,
|
|
15
|
+
isDownloading,
|
|
16
|
+
isPaused,
|
|
17
|
+
getDownloadStatus,
|
|
18
|
+
getAllDownloads,
|
|
19
|
+
type DownloadItem,
|
|
20
|
+
} from './TPStreamsDownload';
|
|
21
|
+
|
|
10
22
|
const TPStreamsModule = NativeModules.TPStreams;
|
|
11
23
|
|
|
12
24
|
export const TPStreams = {
|