react-native-tpstreams 0.2.10 → 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 CHANGED
@@ -89,6 +89,40 @@ import { TPStreamsPlayerView } from "react-native-tpstreams";
89
89
 
90
90
  - `showDefaultCaptions`: (Optional) Whether to show default captions if available. Default is false.
91
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
+
92
126
  ---
93
127
 
94
128
  ## Example
@@ -133,6 +167,7 @@ function TPStreamsPlayerExample() {
133
167
  startAt={100}
134
168
  shouldAutoPlay={false}
135
169
  showDefaultCaptions={true}
170
+ enableDownload={true}
136
171
  onPlayerStateChanged={(state) => console.log(`Player state: ${state}`)}
137
172
  onIsPlayingChanged={(isPlaying) => console.log(`Is playing: ${isPlaying}`)}
138
173
  onPlaybackSpeedChanged={(speed) => console.log(`Speed changed: ${speed}x`)}
@@ -152,12 +187,109 @@ function TPStreamsPlayerExample() {
152
187
 
153
188
  ---
154
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
+
155
289
  ## Contributing
156
290
 
157
291
  See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
158
292
 
159
293
  ## License
160
294
 
161
- MIT
162
-
163
- ---
295
+ MIT
@@ -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.5'
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
  }
@@ -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":[]}
@@ -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 => {
@@ -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,GAAGJ,aAAa,CAACK,SAAS;AAE/C,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAGC,cAAsB,IAAW;IAC5CH,eAAe,CAACE,UAAU,CAACC,cAAc,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
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"}
@@ -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;AAI5D,eAAO,MAAM,SAAS;iCACS,MAAM,KAAG,IAAI;CAG3C,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tpstreams",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Video component for TPStreams",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -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/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 = {