react-native-tpstreams 0.2.15 → 0.2.17
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 +319 -9
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/TPStreamsRNPlayerViewManagerDelegate.java +9 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/TPStreamsRNPlayerViewManagerInterface.java +3 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/TPStreamsPlayerViewSpec/EventEmitters.cpp +9 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/TPStreamsPlayerViewSpec/EventEmitters.h +6 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/TPStreamsPlayerViewSpec/Props.cpp +3 -1
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/TPStreamsPlayerViewSpec/Props.h +2 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/tpstreams/TPStreamsDownloadModule.kt +81 -1
- package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerView.kt +11 -1
- package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerViewManager.kt +5 -0
- package/lib/module/TPStreamsDownload.js +11 -1
- package/lib/module/TPStreamsDownload.js.map +1 -1
- package/lib/module/TPStreamsPlayer.js +2 -0
- package/lib/module/TPStreamsPlayer.js.map +1 -1
- package/lib/module/TPStreamsPlayerViewNativeComponent.ts +1 -0
- 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/TPStreamsPlayer.d.ts +1 -0
- package/lib/typescript/src/TPStreamsPlayer.d.ts.map +1 -1
- package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts +1 -0
- package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.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 +26 -1
- package/src/TPStreamsPlayer.tsx +3 -0
- package/src/TPStreamsPlayerViewNativeComponent.ts +1 -0
- package/src/index.tsx +5 -0
package/README.md
CHANGED
|
@@ -93,6 +93,8 @@ import { TPStreamsPlayerView } from "react-native-tpstreams";
|
|
|
93
93
|
|
|
94
94
|
- `enableDownload`: (Optional) Whether to enable download functionality for the video. When set to true, the player will show a download button. Default is false.
|
|
95
95
|
|
|
96
|
+
- `offlineLicenseExpireTime`: (Optional) The expiration time for offline licenses in seconds. If not provided, defaults to 15 days (1,296,000 seconds).
|
|
97
|
+
|
|
96
98
|
- `downloadMetadata`: (Optional) Custom metadata to attach to downloads. Accepts an object with string key-value pairs. This metadata is stored with the download and can be retrieved later. Default is undefined.
|
|
97
99
|
|
|
98
100
|
---
|
|
@@ -117,15 +119,39 @@ import { TPStreamsPlayerView } from "react-native-tpstreams";
|
|
|
117
119
|
|
|
118
120
|
- `getAllDownloads()`: Gets all downloaded videos. Returns `Promise<DownloadItem[]>`.
|
|
119
121
|
|
|
122
|
+
### Real-time Download Progress
|
|
123
|
+
|
|
124
|
+
The library provides real-time download progress updates for optimal performance:
|
|
125
|
+
|
|
126
|
+
#### Progress Listener Methods
|
|
127
|
+
|
|
128
|
+
- `addDownloadProgressListener()`: Starts listening for download progress updates. Returns `Promise<void>`.
|
|
129
|
+
|
|
130
|
+
- `removeDownloadProgressListener()`: Stops listening for download progress updates. Returns `Promise<void>`.
|
|
131
|
+
|
|
132
|
+
- `onDownloadProgressChanged(listener: DownloadProgressListener)`: Adds a listener for progress changes. Returns `EmitterSubscription`.
|
|
133
|
+
|
|
134
|
+
#### Progress Listener Types
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Progress update event (uses existing DownloadItem interface)
|
|
138
|
+
type DownloadProgressChange = DownloadItem;
|
|
139
|
+
|
|
140
|
+
// Listener function type
|
|
141
|
+
type DownloadProgressListener = (downloads: DownloadProgressChange[]) => void;
|
|
142
|
+
```
|
|
143
|
+
|
|
120
144
|
### Download Item
|
|
121
145
|
|
|
122
146
|
The download item object (`DownloadItem`) contains information about a downloaded or downloading video, including:
|
|
123
147
|
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
126
|
-
- `progressPercentage`: Download progress from 0 to 100.
|
|
127
|
-
- `title`: The title of the video Asset.
|
|
148
|
+
- `videoId`: The ID of the video.
|
|
149
|
+
- `title`: The title of the video.
|
|
128
150
|
- `thumbnailUrl`: URL to the video thumbnail (if available).
|
|
151
|
+
- `totalBytes`: Total size of the video in bytes.
|
|
152
|
+
- `downloadedBytes`: Number of bytes downloaded so far.
|
|
153
|
+
- `progressPercentage`: Download progress from 0 to 100.
|
|
154
|
+
- `state`: The current state of the download as String (Queued, Downloading, Completed, Failed, Removing, Restarting, Paused).
|
|
129
155
|
- `metadata`: Custom metadata attached to the download as a JSON string (if provided during download).
|
|
130
156
|
|
|
131
157
|
---
|
|
@@ -173,6 +199,12 @@ function TPStreamsPlayerExample() {
|
|
|
173
199
|
shouldAutoPlay={false}
|
|
174
200
|
showDefaultCaptions={true}
|
|
175
201
|
enableDownload={true}
|
|
202
|
+
offlineLicenseExpireTime={2 * 24 * 60 * 60} // 2 days in seconds
|
|
203
|
+
downloadMetadata={{
|
|
204
|
+
category: 'educational',
|
|
205
|
+
subject: 'mathematics',
|
|
206
|
+
level: 'intermediate'
|
|
207
|
+
}}
|
|
176
208
|
onPlayerStateChanged={(state) => console.log(`Player state: ${state}`)}
|
|
177
209
|
onIsPlayingChanged={(isPlaying) => console.log(`Is playing: ${isPlaying}`)}
|
|
178
210
|
onPlaybackSpeedChanged={(speed) => console.log(`Speed changed: ${speed}x`)}
|
|
@@ -183,11 +215,6 @@ function TPStreamsPlayerExample() {
|
|
|
183
215
|
const newToken = await getNewTokenForVideo(videoId);
|
|
184
216
|
callback(newToken);
|
|
185
217
|
}}
|
|
186
|
-
downloadMetadata={{
|
|
187
|
-
category: 'educational',
|
|
188
|
-
subject: 'mathematics',
|
|
189
|
-
level: 'intermediate'
|
|
190
|
-
}}
|
|
191
218
|
/>
|
|
192
219
|
|
|
193
220
|
<Button title="Play" onPress={handlePlay} />
|
|
@@ -299,6 +326,289 @@ const removeVideoDownload = async (videoId: string) => {
|
|
|
299
326
|
};
|
|
300
327
|
```
|
|
301
328
|
|
|
329
|
+
## Real-time Download Progress Example
|
|
330
|
+
|
|
331
|
+
Here's a complete example showing how to implement real-time download progress in a React Native component:
|
|
332
|
+
|
|
333
|
+
```jsx
|
|
334
|
+
import React, { useState, useEffect } from 'react';
|
|
335
|
+
import {
|
|
336
|
+
View,
|
|
337
|
+
Text,
|
|
338
|
+
StyleSheet,
|
|
339
|
+
TouchableOpacity,
|
|
340
|
+
ScrollView,
|
|
341
|
+
Alert,
|
|
342
|
+
} from 'react-native';
|
|
343
|
+
import {
|
|
344
|
+
addDownloadProgressListener,
|
|
345
|
+
removeDownloadProgressListener,
|
|
346
|
+
onDownloadProgressChanged,
|
|
347
|
+
pauseDownload,
|
|
348
|
+
resumeDownload,
|
|
349
|
+
removeDownload,
|
|
350
|
+
type DownloadItem,
|
|
351
|
+
type DownloadProgressChange,
|
|
352
|
+
} from 'react-native-tpstreams';
|
|
353
|
+
|
|
354
|
+
const DownloadProgressExample = () => {
|
|
355
|
+
const [downloads, setDownloads] = useState<DownloadItem[]>([]);
|
|
356
|
+
const [isInitializing, setIsInitializing] = useState(true);
|
|
357
|
+
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
let subscription: any = null;
|
|
360
|
+
|
|
361
|
+
// Setup progress listener when component mounts
|
|
362
|
+
const setupProgressListener = async () => {
|
|
363
|
+
try {
|
|
364
|
+
// Start listening for progress updates
|
|
365
|
+
await addDownloadProgressListener();
|
|
366
|
+
|
|
367
|
+
// Add listener for progress updates
|
|
368
|
+
subscription = onDownloadProgressChanged((downloads: DownloadProgressChange[]) => {
|
|
369
|
+
console.log('Progress changes received:', downloads.length, 'downloads');
|
|
370
|
+
|
|
371
|
+
// Simply replace the state with the complete list from native
|
|
372
|
+
setDownloads(downloads);
|
|
373
|
+
});
|
|
374
|
+
} catch (error) {
|
|
375
|
+
console.error('Failed to setup progress listener:', error);
|
|
376
|
+
setIsInitializing(false);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
setupProgressListener();
|
|
381
|
+
|
|
382
|
+
// Cleanup function - moved outside async function
|
|
383
|
+
return () => {
|
|
384
|
+
if (subscription) {
|
|
385
|
+
subscription.remove(); // Remove the listener
|
|
386
|
+
}
|
|
387
|
+
removeDownloadProgressListener(); // Stop listening
|
|
388
|
+
};
|
|
389
|
+
}, []);
|
|
390
|
+
|
|
391
|
+
const handlePauseDownload = async (videoId: string) => {
|
|
392
|
+
try {
|
|
393
|
+
await pauseDownload(videoId);
|
|
394
|
+
console.log('Download paused successfully');
|
|
395
|
+
} catch (error) {
|
|
396
|
+
console.error('Error pausing download:', error);
|
|
397
|
+
Alert.alert('Error', 'Failed to pause download');
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
const handleResumeDownload = async (videoId: string) => {
|
|
402
|
+
try {
|
|
403
|
+
await resumeDownload(videoId);
|
|
404
|
+
console.log('Download resumed successfully');
|
|
405
|
+
} catch (error) {
|
|
406
|
+
console.error('Error resuming download:', error);
|
|
407
|
+
Alert.alert('Error', 'Failed to resume download');
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
const handleRemoveDownload = async (videoId: string) => {
|
|
412
|
+
try {
|
|
413
|
+
await removeDownload(videoId);
|
|
414
|
+
console.log('Download removed successfully');
|
|
415
|
+
} catch (error) {
|
|
416
|
+
console.error('Error removing download:', error);
|
|
417
|
+
Alert.alert('Error', 'Failed to remove download');
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const renderDownloadItem = (item: DownloadItem) => {
|
|
422
|
+
const isCompleted = item.state === 'Completed';
|
|
423
|
+
const isDownloading = item.state === 'Downloading';
|
|
424
|
+
const isPaused = item.state === 'Paused';
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<View key={item.videoId} style={styles.downloadItem}>
|
|
428
|
+
<Text style={styles.title}>{item.title}</Text>
|
|
429
|
+
<Text style={styles.status}>Status: {item.state}</Text>
|
|
430
|
+
|
|
431
|
+
{!isCompleted && (
|
|
432
|
+
<View style={styles.progressContainer}>
|
|
433
|
+
<View style={styles.progressBar}>
|
|
434
|
+
<View
|
|
435
|
+
style={[
|
|
436
|
+
styles.progressFill,
|
|
437
|
+
{ width: `${item.progressPercentage}%` }
|
|
438
|
+
]}
|
|
439
|
+
/>
|
|
440
|
+
</View>
|
|
441
|
+
<Text style={styles.progressText}>
|
|
442
|
+
{item.progressPercentage.toFixed(1)}%
|
|
443
|
+
</Text>
|
|
444
|
+
</View>
|
|
445
|
+
)}
|
|
446
|
+
|
|
447
|
+
{item.totalBytes > 0 && (
|
|
448
|
+
<Text style={styles.bytesText}>
|
|
449
|
+
{(item.downloadedBytes / (1024 * 1024)).toFixed(1)} MB /
|
|
450
|
+
{(item.totalBytes / (1024 * 1024)).toFixed(1)} MB
|
|
451
|
+
</Text>
|
|
452
|
+
)}
|
|
453
|
+
|
|
454
|
+
<View style={styles.buttonContainer}>
|
|
455
|
+
{!isCompleted && (
|
|
456
|
+
<>
|
|
457
|
+
{isDownloading && (
|
|
458
|
+
<TouchableOpacity
|
|
459
|
+
style={styles.button}
|
|
460
|
+
onPress={() => handlePauseDownload(item.videoId)}
|
|
461
|
+
>
|
|
462
|
+
<Text style={styles.buttonText}>Pause</Text>
|
|
463
|
+
</TouchableOpacity>
|
|
464
|
+
)}
|
|
465
|
+
|
|
466
|
+
{isPaused && (
|
|
467
|
+
<TouchableOpacity
|
|
468
|
+
style={styles.button}
|
|
469
|
+
onPress={() => handleResumeDownload(item.videoId)}
|
|
470
|
+
>
|
|
471
|
+
<Text style={styles.buttonText}>Resume</Text>
|
|
472
|
+
</TouchableOpacity>
|
|
473
|
+
)}
|
|
474
|
+
</>
|
|
475
|
+
)}
|
|
476
|
+
|
|
477
|
+
<TouchableOpacity
|
|
478
|
+
style={[styles.button, styles.removeButton]}
|
|
479
|
+
onPress={() => handleRemoveDownload(item.videoId)}
|
|
480
|
+
>
|
|
481
|
+
<Text style={styles.buttonText}>Remove</Text>
|
|
482
|
+
</TouchableOpacity>
|
|
483
|
+
</View>
|
|
484
|
+
</View>
|
|
485
|
+
);
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
if (isInitializing) {
|
|
489
|
+
return (
|
|
490
|
+
<View style={styles.container}>
|
|
491
|
+
<Text>Loading downloads...</Text>
|
|
492
|
+
</View>
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return (
|
|
497
|
+
<ScrollView style={styles.container}>
|
|
498
|
+
<Text style={styles.header}>Downloads ({downloads.length})</Text>
|
|
499
|
+
|
|
500
|
+
{downloads.length > 0 ? (
|
|
501
|
+
downloads.map(renderDownloadItem)
|
|
502
|
+
) : (
|
|
503
|
+
<Text style={styles.emptyText}>No downloads available</Text>
|
|
504
|
+
)}
|
|
505
|
+
</ScrollView>
|
|
506
|
+
);
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const styles = StyleSheet.create({
|
|
510
|
+
container: {
|
|
511
|
+
flex: 1,
|
|
512
|
+
padding: 16,
|
|
513
|
+
backgroundColor: '#f5f5f5',
|
|
514
|
+
},
|
|
515
|
+
header: {
|
|
516
|
+
fontSize: 20,
|
|
517
|
+
fontWeight: 'bold',
|
|
518
|
+
marginBottom: 16,
|
|
519
|
+
},
|
|
520
|
+
downloadItem: {
|
|
521
|
+
backgroundColor: '#fff',
|
|
522
|
+
padding: 16,
|
|
523
|
+
marginBottom: 12,
|
|
524
|
+
borderRadius: 8,
|
|
525
|
+
shadowColor: '#000',
|
|
526
|
+
shadowOffset: { width: 0, height: 2 },
|
|
527
|
+
shadowOpacity: 0.1,
|
|
528
|
+
shadowRadius: 4,
|
|
529
|
+
elevation: 3,
|
|
530
|
+
},
|
|
531
|
+
title: {
|
|
532
|
+
fontSize: 16,
|
|
533
|
+
fontWeight: 'bold',
|
|
534
|
+
marginBottom: 8,
|
|
535
|
+
},
|
|
536
|
+
status: {
|
|
537
|
+
fontSize: 14,
|
|
538
|
+
color: '#666',
|
|
539
|
+
marginBottom: 8,
|
|
540
|
+
},
|
|
541
|
+
progressContainer: {
|
|
542
|
+
flexDirection: 'row',
|
|
543
|
+
alignItems: 'center',
|
|
544
|
+
marginBottom: 8,
|
|
545
|
+
},
|
|
546
|
+
progressBar: {
|
|
547
|
+
flex: 1,
|
|
548
|
+
height: 8,
|
|
549
|
+
backgroundColor: '#eee',
|
|
550
|
+
borderRadius: 4,
|
|
551
|
+
marginRight: 12,
|
|
552
|
+
},
|
|
553
|
+
progressFill: {
|
|
554
|
+
height: '100%',
|
|
555
|
+
backgroundColor: '#007AFF',
|
|
556
|
+
borderRadius: 4,
|
|
557
|
+
},
|
|
558
|
+
progressText: {
|
|
559
|
+
fontSize: 12,
|
|
560
|
+
color: '#666',
|
|
561
|
+
width: 40,
|
|
562
|
+
},
|
|
563
|
+
bytesText: {
|
|
564
|
+
fontSize: 12,
|
|
565
|
+
color: '#666',
|
|
566
|
+
marginBottom: 12,
|
|
567
|
+
},
|
|
568
|
+
buttonContainer: {
|
|
569
|
+
flexDirection: 'row',
|
|
570
|
+
gap: 8,
|
|
571
|
+
},
|
|
572
|
+
button: {
|
|
573
|
+
paddingVertical: 8,
|
|
574
|
+
paddingHorizontal: 16,
|
|
575
|
+
backgroundColor: '#007AFF',
|
|
576
|
+
borderRadius: 6,
|
|
577
|
+
},
|
|
578
|
+
removeButton: {
|
|
579
|
+
backgroundColor: '#FF3B30',
|
|
580
|
+
},
|
|
581
|
+
buttonText: {
|
|
582
|
+
color: '#fff',
|
|
583
|
+
fontSize: 14,
|
|
584
|
+
fontWeight: '600',
|
|
585
|
+
},
|
|
586
|
+
emptyText: {
|
|
587
|
+
textAlign: 'center',
|
|
588
|
+
color: '#666',
|
|
589
|
+
fontSize: 16,
|
|
590
|
+
},
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
export default DownloadProgressExample;
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### Key Features of the Real-time Progress System:
|
|
597
|
+
|
|
598
|
+
1. **Real-time Updates**: Progress bars and status update in real-time
|
|
599
|
+
2. **Automatic UI Updates**: UI automatically reflects current download states
|
|
600
|
+
3. **Efficient State Management**: Uses functional state updates to avoid race conditions
|
|
601
|
+
4. **Proper Cleanup**: Removes listeners when component unmounts
|
|
602
|
+
5. **Error Handling**: Graceful error handling with user feedback
|
|
603
|
+
6. **Type Safety**: Full TypeScript support with proper types
|
|
604
|
+
|
|
605
|
+
### Best Practices:
|
|
606
|
+
|
|
607
|
+
1. **Start listening when needed**: Only start the progress listener when your screen is active
|
|
608
|
+
2. **Stop listening when not needed**: Always stop listening to save resources
|
|
609
|
+
3. **Use functional state updates**: Prevents race conditions with concurrent updates
|
|
610
|
+
4. **Debounce if needed**: Consider debouncing updates for better UI performance
|
|
611
|
+
|
|
302
612
|
---
|
|
303
613
|
|
|
304
614
|
## Contributing
|
|
@@ -41,6 +41,12 @@ public class TPStreamsRNPlayerViewManagerDelegate<T extends View, U extends Base
|
|
|
41
41
|
case "showDefaultCaptions":
|
|
42
42
|
mViewManager.setShowDefaultCaptions(view, value == null ? false : (boolean) value);
|
|
43
43
|
break;
|
|
44
|
+
case "downloadMetadata":
|
|
45
|
+
mViewManager.setDownloadMetadata(view, value == null ? null : (String) value);
|
|
46
|
+
break;
|
|
47
|
+
case "offlineLicenseExpireTime":
|
|
48
|
+
mViewManager.setOfflineLicenseExpireTime(view, value == null ? 0f : ((Double) value).doubleValue());
|
|
49
|
+
break;
|
|
44
50
|
default:
|
|
45
51
|
super.setProperty(view, propName, value);
|
|
46
52
|
}
|
|
@@ -73,6 +79,9 @@ public class TPStreamsRNPlayerViewManagerDelegate<T extends View, U extends Base
|
|
|
73
79
|
case "getPlaybackSpeed":
|
|
74
80
|
mViewManager.getPlaybackSpeed(view);
|
|
75
81
|
break;
|
|
82
|
+
case "setNewAccessToken":
|
|
83
|
+
mViewManager.setNewAccessToken(view, args.getString(0));
|
|
84
|
+
break;
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
}
|
|
@@ -20,6 +20,8 @@ public interface TPStreamsRNPlayerViewManagerInterface<T extends View> extends V
|
|
|
20
20
|
void setStartAt(T view, double value);
|
|
21
21
|
void setEnableDownload(T view, boolean value);
|
|
22
22
|
void setShowDefaultCaptions(T view, boolean value);
|
|
23
|
+
void setDownloadMetadata(T view, @Nullable String value);
|
|
24
|
+
void setOfflineLicenseExpireTime(T view, double value);
|
|
23
25
|
void play(T view);
|
|
24
26
|
void pause(T view);
|
|
25
27
|
void seekTo(T view, double positionMs);
|
|
@@ -28,4 +30,5 @@ public interface TPStreamsRNPlayerViewManagerInterface<T extends View> extends V
|
|
|
28
30
|
void getDuration(T view);
|
|
29
31
|
void isPlaying(T view);
|
|
30
32
|
void getPlaybackSpeed(T view);
|
|
33
|
+
void setNewAccessToken(T view, String newToken);
|
|
31
34
|
}
|
|
@@ -95,4 +95,13 @@ $payload.setProperty(runtime, "details", $event.details);
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
|
|
99
|
+
void TPStreamsRNPlayerViewEventEmitter::onAccessTokenExpired(OnAccessTokenExpired $event) const {
|
|
100
|
+
dispatchEvent("accessTokenExpired", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
101
|
+
auto $payload = jsi::Object(runtime);
|
|
102
|
+
$payload.setProperty(runtime, "videoId", $event.videoId);
|
|
103
|
+
return $payload;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
} // namespace facebook::react
|
|
@@ -54,6 +54,10 @@ class TPStreamsRNPlayerViewEventEmitter : public ViewEventEmitter {
|
|
|
54
54
|
int code;
|
|
55
55
|
std::string details;
|
|
56
56
|
};
|
|
57
|
+
|
|
58
|
+
struct OnAccessTokenExpired {
|
|
59
|
+
std::string videoId;
|
|
60
|
+
};
|
|
57
61
|
void onCurrentPosition(OnCurrentPosition value) const;
|
|
58
62
|
|
|
59
63
|
void onDuration(OnDuration value) const;
|
|
@@ -71,5 +75,7 @@ class TPStreamsRNPlayerViewEventEmitter : public ViewEventEmitter {
|
|
|
71
75
|
void onIsLoadingChanged(OnIsLoadingChanged value) const;
|
|
72
76
|
|
|
73
77
|
void onError(OnError value) const;
|
|
78
|
+
|
|
79
|
+
void onAccessTokenExpired(OnAccessTokenExpired value) const;
|
|
74
80
|
};
|
|
75
81
|
} // namespace facebook::react
|
|
@@ -24,7 +24,9 @@ TPStreamsRNPlayerViewProps::TPStreamsRNPlayerViewProps(
|
|
|
24
24
|
shouldAutoPlay(convertRawProp(context, rawProps, "shouldAutoPlay", sourceProps.shouldAutoPlay, {false})),
|
|
25
25
|
startAt(convertRawProp(context, rawProps, "startAt", sourceProps.startAt, {0.0})),
|
|
26
26
|
enableDownload(convertRawProp(context, rawProps, "enableDownload", sourceProps.enableDownload, {false})),
|
|
27
|
-
showDefaultCaptions(convertRawProp(context, rawProps, "showDefaultCaptions", sourceProps.showDefaultCaptions, {false}))
|
|
27
|
+
showDefaultCaptions(convertRawProp(context, rawProps, "showDefaultCaptions", sourceProps.showDefaultCaptions, {false})),
|
|
28
|
+
downloadMetadata(convertRawProp(context, rawProps, "downloadMetadata", sourceProps.downloadMetadata, {})),
|
|
29
|
+
offlineLicenseExpireTime(convertRawProp(context, rawProps, "offlineLicenseExpireTime", sourceProps.offlineLicenseExpireTime, {0.0}))
|
|
28
30
|
{}
|
|
29
31
|
|
|
30
32
|
} // namespace facebook::react
|
|
@@ -27,6 +27,8 @@ class TPStreamsRNPlayerViewProps final : public ViewProps {
|
|
|
27
27
|
double startAt{0.0};
|
|
28
28
|
bool enableDownload{false};
|
|
29
29
|
bool showDefaultCaptions{false};
|
|
30
|
+
std::string downloadMetadata{};
|
|
31
|
+
double offlineLicenseExpireTime{0.0};
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
} // namespace facebook::react
|
|
@@ -6,19 +6,99 @@ 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.modules.core.DeviceEventManagerModule
|
|
9
10
|
import com.tpstreams.player.download.DownloadClient
|
|
10
11
|
import com.tpstreams.player.download.DownloadItem
|
|
11
12
|
|
|
12
|
-
class TPStreamsDownloadModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
13
|
+
class TPStreamsDownloadModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext), DownloadClient.Listener {
|
|
13
14
|
|
|
14
15
|
private val downloadClient: DownloadClient by lazy {
|
|
15
16
|
DownloadClient.getInstance(reactContext)
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
private var isListening = false
|
|
20
|
+
|
|
18
21
|
override fun getName(): String {
|
|
19
22
|
return "TPStreamsDownload"
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
@ReactMethod
|
|
26
|
+
fun addDownloadProgressListener(promise: Promise) {
|
|
27
|
+
try {
|
|
28
|
+
if (!isListening) {
|
|
29
|
+
downloadClient.addListener(this)
|
|
30
|
+
isListening = true
|
|
31
|
+
Log.d(TAG, "Started listening for download progress")
|
|
32
|
+
}
|
|
33
|
+
promise.resolve(null)
|
|
34
|
+
} catch (e: Exception) {
|
|
35
|
+
Log.e(TAG, "Error starting progress listener: ${e.message}", e)
|
|
36
|
+
promise.reject("PROGRESS_LISTENER_START_ERROR", e.message, e)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@ReactMethod
|
|
41
|
+
fun removeDownloadProgressListener(promise: Promise) {
|
|
42
|
+
try {
|
|
43
|
+
if (isListening) {
|
|
44
|
+
downloadClient.removeListener(this)
|
|
45
|
+
isListening = false
|
|
46
|
+
Log.d(TAG, "Stopped listening for download progress")
|
|
47
|
+
}
|
|
48
|
+
promise.resolve(null)
|
|
49
|
+
} catch (e: Exception) {
|
|
50
|
+
Log.e(TAG, "Error stopping progress listener: ${e.message}", e)
|
|
51
|
+
promise.reject("PROGRESS_LISTENER_STOP_ERROR", e.message, e)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
fun addListener(eventName: String) {
|
|
57
|
+
// Required by NativeEventEmitter - no action needed
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@ReactMethod
|
|
61
|
+
fun removeListeners(count: Int) {
|
|
62
|
+
// Required by NativeEventEmitter - no action needed
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun onDownloadsChanged() {
|
|
66
|
+
try {
|
|
67
|
+
val currentDownloads = downloadClient.getAllDownloadItems()
|
|
68
|
+
|
|
69
|
+
val result = Arguments.createArray()
|
|
70
|
+
for (item in currentDownloads) {
|
|
71
|
+
val map = Arguments.createMap()
|
|
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
|
+
|
|
86
|
+
result.pushMap(map)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
emitEvent("onDownloadProgressChanged", result)
|
|
90
|
+
|
|
91
|
+
} catch (e: Exception) {
|
|
92
|
+
Log.e(TAG, "Error in onDownloadsChanged: ${e.message}", e)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private fun emitEvent(eventName: String, data: Any) {
|
|
97
|
+
reactContext
|
|
98
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
99
|
+
.emit(eventName, data)
|
|
100
|
+
}
|
|
101
|
+
|
|
22
102
|
@ReactMethod
|
|
23
103
|
fun pauseDownload(videoId: String, promise: Promise) {
|
|
24
104
|
try {
|
|
@@ -17,6 +17,10 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
17
17
|
private var player: TPStreamsPlayer? = null
|
|
18
18
|
private val reactContext: ReactContext = context
|
|
19
19
|
|
|
20
|
+
companion object {
|
|
21
|
+
private const val DEFAULT_OFFLINE_LICENSE_EXPIRE_TIME = 15L * 24L * 60L * 60L // 15 days in seconds
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
private var videoId: String? = null
|
|
21
25
|
private var accessToken: String? = null
|
|
22
26
|
private var shouldAutoPlay: Boolean = true
|
|
@@ -24,6 +28,7 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
24
28
|
private var showDefaultCaptions: Boolean = false
|
|
25
29
|
private var enableDownload: Boolean = false
|
|
26
30
|
private var downloadMetadata: Map<String, String>? = null
|
|
31
|
+
private var offlineLicenseExpireTime: Long = DEFAULT_OFFLINE_LICENSE_EXPIRE_TIME
|
|
27
32
|
private var accessTokenCallback: ((String) -> Unit)? = null
|
|
28
33
|
|
|
29
34
|
init {
|
|
@@ -83,6 +88,10 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
83
88
|
this.downloadMetadata = metadata
|
|
84
89
|
}
|
|
85
90
|
|
|
91
|
+
fun setOfflineLicenseExpireTime(expireTime: Long?) {
|
|
92
|
+
this.offlineLicenseExpireTime = expireTime ?: DEFAULT_OFFLINE_LICENSE_EXPIRE_TIME
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
fun setNewAccessToken(newToken: String) {
|
|
87
96
|
Log.d("TPStreamsRNPlayerView", "Setting new access token")
|
|
88
97
|
accessTokenCallback?.let { callback ->
|
|
@@ -104,7 +113,8 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
|
|
|
104
113
|
startAt,
|
|
105
114
|
enableDownload,
|
|
106
115
|
showDefaultCaptions,
|
|
107
|
-
downloadMetadata
|
|
116
|
+
downloadMetadata,
|
|
117
|
+
offlineLicenseExpireTime
|
|
108
118
|
)
|
|
109
119
|
|
|
110
120
|
player?.listener = object : TPStreamsPlayer.Listener {
|
|
@@ -84,6 +84,11 @@ class TPStreamsRNPlayerViewManager : SimpleViewManager<TPStreamsRNPlayerView>(),
|
|
|
84
84
|
view.setEnableDownload(enableDownload)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
@ReactProp(name = "offlineLicenseExpireTime")
|
|
88
|
+
override fun setOfflineLicenseExpireTime(view: TPStreamsRNPlayerView, expireTime: Double) {
|
|
89
|
+
view.setOfflineLicenseExpireTime(expireTime.toLong())
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
@ReactProp(name = "downloadMetadata")
|
|
88
93
|
override fun setDownloadMetadata(view: TPStreamsRNPlayerView, metadata: String?) {
|
|
89
94
|
val metadataMap = if (!metadata.isNullOrEmpty()) {
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { NativeModules } from 'react-native';
|
|
3
|
+
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
4
4
|
const {
|
|
5
5
|
TPStreamsDownload
|
|
6
6
|
} = NativeModules;
|
|
7
|
+
const downloadEventEmitter = new NativeEventEmitter(TPStreamsDownload);
|
|
8
|
+
export function addDownloadProgressListener() {
|
|
9
|
+
return TPStreamsDownload.addDownloadProgressListener();
|
|
10
|
+
}
|
|
11
|
+
export function removeDownloadProgressListener() {
|
|
12
|
+
return TPStreamsDownload.removeDownloadProgressListener();
|
|
13
|
+
}
|
|
14
|
+
export function onDownloadProgressChanged(listener) {
|
|
15
|
+
return downloadEventEmitter.addListener('onDownloadProgressChanged', listener);
|
|
16
|
+
}
|
|
7
17
|
export function pauseDownload(videoId) {
|
|
8
18
|
return TPStreamsDownload.pauseDownload(videoId);
|
|
9
19
|
}
|
|
@@ -1 +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;
|
|
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;AAkB3C,MAAMG,oBAAoB,GAAG,IAAIF,kBAAkB,CAACC,iBAAiB,CAAC;AAEtE,OAAO,SAASE,2BAA2BA,CAAA,EAAkB;EAC3D,OAAOF,iBAAiB,CAACE,2BAA2B,CAAC,CAAC;AACxD;AAEA,OAAO,SAASC,8BAA8BA,CAAA,EAAkB;EAC9D,OAAOH,iBAAiB,CAACG,8BAA8B,CAAC,CAAC;AAC3D;AAEA,OAAO,SAASC,yBAAyBA,CACvCC,QAAkC,EACb;EACrB,OAAOJ,oBAAoB,CAACK,WAAW,CACrC,2BAA2B,EAC3BD,QACF,CAAC;AACH;AAEA,OAAO,SAASE,aAAaA,CAACC,OAAe,EAAiB;EAC5D,OAAOR,iBAAiB,CAACO,aAAa,CAACC,OAAO,CAAC;AACjD;AAEA,OAAO,SAASC,cAAcA,CAACD,OAAe,EAAiB;EAC7D,OAAOR,iBAAiB,CAACS,cAAc,CAACD,OAAO,CAAC;AAClD;AAEA,OAAO,SAASE,cAAcA,CAACF,OAAe,EAAiB;EAC7D,OAAOR,iBAAiB,CAACU,cAAc,CAACF,OAAO,CAAC;AAClD;AAEA,OAAO,SAASG,YAAYA,CAACH,OAAe,EAAoB;EAC9D,OAAOR,iBAAiB,CAACW,YAAY,CAACH,OAAO,CAAC;AAChD;AAEA,OAAO,SAASI,aAAaA,CAACJ,OAAe,EAAoB;EAC/D,OAAOR,iBAAiB,CAACY,aAAa,CAACJ,OAAO,CAAC;AACjD;AAEA,OAAO,SAASK,QAAQA,CAACL,OAAe,EAAoB;EAC1D,OAAOR,iBAAiB,CAACa,QAAQ,CAACL,OAAO,CAAC;AAC5C;AAEA,OAAO,SAASM,iBAAiBA,CAACN,OAAe,EAAmB;EAClE,OAAOR,iBAAiB,CAACc,iBAAiB,CAACN,OAAO,CAAC;AACrD;AAEA,OAAO,SAASO,eAAeA,CAAA,EAA4B;EACzD,OAAOf,iBAAiB,CAACe,eAAe,CAAC,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -23,6 +23,7 @@ const TPStreamsPlayerView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
23
23
|
shouldAutoPlay,
|
|
24
24
|
startAt,
|
|
25
25
|
enableDownload,
|
|
26
|
+
offlineLicenseExpireTime,
|
|
26
27
|
showDefaultCaptions,
|
|
27
28
|
downloadMetadata,
|
|
28
29
|
style,
|
|
@@ -164,6 +165,7 @@ const TPStreamsPlayerView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
164
165
|
enableDownload,
|
|
165
166
|
showDefaultCaptions,
|
|
166
167
|
downloadMetadata: downloadMetadata ? JSON.stringify(downloadMetadata) : undefined,
|
|
168
|
+
offlineLicenseExpireTime,
|
|
167
169
|
style,
|
|
168
170
|
onCurrentPosition,
|
|
169
171
|
onDuration,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useImperativeHandle","useRef","useCallback","TPStreamsPlayerNative","Commands","jsx","_jsx","nextInstanceId","TPStreamsPlayerView","props","ref","videoId","accessToken","shouldAutoPlay","startAt","enableDownload","showDefaultCaptions","downloadMetadata","style","onPlayerStateChanged","onIsPlayingChanged","onPlaybackSpeedChanged","onIsLoadingChanged","onError","onAccessTokenExpired","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","handleAccessTokenExpired","expiredVideoId","newToken","setNewAccessToken","console","error","createPromiseMethod","command","eventKey","Promise","setTimeout","play","pause","seekTo","positionMs","setPlaybackSpeed","getCurrentPosition","getDuration","getPlaybackSpeed","nativeProps","JSON","stringify","undefined"],"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","offlineLicenseExpireTime","showDefaultCaptions","downloadMetadata","style","onPlayerStateChanged","onIsPlayingChanged","onPlaybackSpeedChanged","onIsLoadingChanged","onError","onAccessTokenExpired","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","handleAccessTokenExpired","expiredVideoId","newToken","setNewAccessToken","console","error","createPromiseMethod","command","eventKey","Promise","setTimeout","play","pause","seekTo","positionMs","setPlaybackSpeed","getCurrentPosition","getDuration","getPlaybackSpeed","nativeProps","JSON","stringify","undefined"],"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;;AAyBA;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,wBAAwB;IACxBC,mBAAmB;IACnBC,gBAAgB;IAChBC,KAAK;IACLC,oBAAoB;IACpBC,kBAAkB;IAClBC,sBAAsB;IACtBC,kBAAkB;IAClBC,OAAO;IACPC,oBAAoB;IACpB,GAAGC;EACL,CAAC,GAAGjB,KAAK;EAET,MAAMkB,SAAS,GAAG1B,MAAM,CAAC,IAAI,CAAC;EAC9B,MAAM2B,UAAU,GAAG3B,MAAM,CAASM,cAAc,EAAE,CAAC;EACnD,MAAMsB,UAAU,G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AAc;IACdE,mBAAmB;IACnBC,gBAAgB,EAAEA,gBAAgB,GAC9B6D,IAAI,CAACC,SAAS,CAAC9D,gBAAgB,CAAC,GAChC+D,SAAS;IACbjE,wBAAwB;IACxBG,KAAK;IACLW,iBAAiB;IACjBQ,UAAU;IACVE,WAAW;IACXE,eAAe;IACftB,oBAAoB,EAAEwB,wBAAwB;IAC9CvB,kBAAkB,EAAEyB,sBAAsB;IAC1CxB,sBAAsB,EAAEyB,0BAA0B;IAClDxB,kBAAkB,EAAEyB,sBAAsB;IAC1CxB,OAAO,EAAE0B,WAAW;IACpBzB,oBAAoB,EAAEkC;EACxB,CAAC;EAED,oBAAOrD,IAAA,CAACH,qBAAqB;IAAA,GAAK2E,WAAW;IAAEpE,GAAG,EAAEiB;EAAU,CAAE,CAAC;AACnE,CAAC,CAAC;AAEF,eAAenB,mBAAmB","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 } from "./TPStreamsDownload.js";
|
|
10
|
+
export { pauseDownload, resumeDownload, removeDownload, isDownloaded, isDownloading, isPaused, getDownloadStatus, getAllDownloads, addDownloadProgressListener, removeDownloadProgressListener, onDownloadProgressChanged } 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","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,
|
|
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,QAIpB,wBAAqB;AAE5B,MAAMC,eAAe,GAAGf,aAAa,CAACgB,SAAS;AAE/C,OAAO,MAAMA,SAAS,GAAG;EACvBC,UAAU,EAAGC,cAAsB,IAAW;IAC5CH,eAAe,CAACE,UAAU,CAACC,cAAc,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EmitterSubscription } from 'react-native';
|
|
1
2
|
export interface DownloadItem {
|
|
2
3
|
videoId: string;
|
|
3
4
|
title: string;
|
|
@@ -8,6 +9,11 @@ export interface DownloadItem {
|
|
|
8
9
|
state: string;
|
|
9
10
|
metadata: string;
|
|
10
11
|
}
|
|
12
|
+
export type DownloadProgressChange = DownloadItem;
|
|
13
|
+
export type DownloadProgressListener = (downloads: DownloadProgressChange[]) => void;
|
|
14
|
+
export declare function addDownloadProgressListener(): Promise<void>;
|
|
15
|
+
export declare function removeDownloadProgressListener(): Promise<void>;
|
|
16
|
+
export declare function onDownloadProgressChanged(listener: DownloadProgressListener): EmitterSubscription;
|
|
11
17
|
export declare function pauseDownload(videoId: string): Promise<void>;
|
|
12
18
|
export declare function resumeDownload(videoId: string): Promise<void>;
|
|
13
19
|
export declare function removeDownload(videoId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TPStreamsDownload.d.ts","sourceRoot":"","sources":["../../../src/TPStreamsDownload.tsx"],"names":[],"mappings":"
|
|
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,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KAAK,IAAI,CAAC;IACX,oBAAoB,CAAC,EAAE,CACrB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,KACjC,IAAI,CAAC;CACX;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,qHAsMvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
|
@@ -15,6 +15,7 @@ export interface NativeProps extends ViewProps {
|
|
|
15
15
|
shouldAutoPlay?: boolean;
|
|
16
16
|
startAt?: Double;
|
|
17
17
|
enableDownload?: boolean;
|
|
18
|
+
offlineLicenseExpireTime?: Double;
|
|
18
19
|
showDefaultCaptions?: boolean;
|
|
19
20
|
downloadMetadata?: string;
|
|
20
21
|
onCurrentPosition?: DirectEventHandler<{
|
|
@@ -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;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,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W,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;IACV,iBAAiB,EAAE,CACjB,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,EACrD,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;CACX;AAED,eAAO,MAAM,QAAQ,6BAYnB,CAAC;;AAEH,wBAA4E"}
|
|
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,CA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ViewNativeCom
|
|
|
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
|
+
export { pauseDownload, resumeDownload, removeDownload, isDownloaded, isDownloading, isPaused, getDownloadStatus, getAllDownloads, addDownloadProgressListener, removeDownloadProgressListener, onDownloadProgressChanged, type DownloadItem, type DownloadProgressChange, type DownloadProgressListener, } 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,KAAK,YAAY,
|
|
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,GAC9B,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,SAAS;iCACS,MAAM,KAAG,IAAI;CAG3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import type { EmitterSubscription } from 'react-native';
|
|
2
3
|
|
|
3
4
|
const { TPStreamsDownload } = NativeModules;
|
|
4
5
|
|
|
@@ -13,6 +14,30 @@ export interface DownloadItem {
|
|
|
13
14
|
metadata: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
export type DownloadProgressChange = DownloadItem;
|
|
18
|
+
export type DownloadProgressListener = (
|
|
19
|
+
downloads: DownloadProgressChange[]
|
|
20
|
+
) => void;
|
|
21
|
+
|
|
22
|
+
const downloadEventEmitter = new NativeEventEmitter(TPStreamsDownload);
|
|
23
|
+
|
|
24
|
+
export function addDownloadProgressListener(): Promise<void> {
|
|
25
|
+
return TPStreamsDownload.addDownloadProgressListener();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function removeDownloadProgressListener(): Promise<void> {
|
|
29
|
+
return TPStreamsDownload.removeDownloadProgressListener();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function onDownloadProgressChanged(
|
|
33
|
+
listener: DownloadProgressListener
|
|
34
|
+
): EmitterSubscription {
|
|
35
|
+
return downloadEventEmitter.addListener(
|
|
36
|
+
'onDownloadProgressChanged',
|
|
37
|
+
listener
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
16
41
|
export function pauseDownload(videoId: string): Promise<void> {
|
|
17
42
|
return TPStreamsDownload.pauseDownload(videoId);
|
|
18
43
|
}
|
package/src/TPStreamsPlayer.tsx
CHANGED
|
@@ -38,6 +38,7 @@ export interface TPStreamsPlayerProps extends ViewProps {
|
|
|
38
38
|
shouldAutoPlay?: boolean;
|
|
39
39
|
startAt?: number;
|
|
40
40
|
enableDownload?: boolean;
|
|
41
|
+
offlineLicenseExpireTime?: number;
|
|
41
42
|
showDefaultCaptions?: boolean;
|
|
42
43
|
downloadMetadata?: { [key: string]: string };
|
|
43
44
|
onPlayerStateChanged?: (state: number) => void;
|
|
@@ -69,6 +70,7 @@ const TPStreamsPlayerView = forwardRef<
|
|
|
69
70
|
shouldAutoPlay,
|
|
70
71
|
startAt,
|
|
71
72
|
enableDownload,
|
|
73
|
+
offlineLicenseExpireTime,
|
|
72
74
|
showDefaultCaptions,
|
|
73
75
|
downloadMetadata,
|
|
74
76
|
style,
|
|
@@ -241,6 +243,7 @@ const TPStreamsPlayerView = forwardRef<
|
|
|
241
243
|
downloadMetadata: downloadMetadata
|
|
242
244
|
? JSON.stringify(downloadMetadata)
|
|
243
245
|
: undefined,
|
|
246
|
+
offlineLicenseExpireTime,
|
|
244
247
|
style,
|
|
245
248
|
onCurrentPosition,
|
|
246
249
|
onDuration,
|
package/src/index.tsx
CHANGED
|
@@ -16,7 +16,12 @@ export {
|
|
|
16
16
|
isPaused,
|
|
17
17
|
getDownloadStatus,
|
|
18
18
|
getAllDownloads,
|
|
19
|
+
addDownloadProgressListener,
|
|
20
|
+
removeDownloadProgressListener,
|
|
21
|
+
onDownloadProgressChanged,
|
|
19
22
|
type DownloadItem,
|
|
23
|
+
type DownloadProgressChange,
|
|
24
|
+
type DownloadProgressListener,
|
|
20
25
|
} from './TPStreamsDownload';
|
|
21
26
|
|
|
22
27
|
const TPStreamsModule = NativeModules.TPStreams;
|