react-native-tpstreams 0.1.14 → 0.2.0

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.
Files changed (71) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +20 -418
  3. package/Tpstreams.podspec +3 -25
  4. package/android/build.gradle +14 -42
  5. package/android/src/main/AndroidManifest.xml +1 -3
  6. package/android/src/main/java/com/tpstreams/TPStreamsRNModule.kt +18 -0
  7. package/android/src/main/java/com/tpstreams/{TpstreamsPackage.kt → TPStreamsRNPackage.kt} +10 -5
  8. package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerView.kt +53 -0
  9. package/android/src/main/java/com/tpstreams/TPStreamsRNPlayerViewManager.kt +46 -0
  10. package/ios/TpstreamsView.h +14 -0
  11. package/ios/TpstreamsView.mm +71 -0
  12. package/ios/TpstreamsViewManager.mm +19 -0
  13. package/lib/module/TPStreamsPlayerViewNativeComponent.ts +9 -0
  14. package/lib/module/index.js +9 -3
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/typescript/package.json +1 -0
  17. package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts +9 -0
  18. package/lib/typescript/src/TPStreamsPlayerViewNativeComponent.d.ts.map +1 -0
  19. package/lib/typescript/src/index.d.ts +6 -0
  20. package/lib/typescript/src/index.d.ts.map +1 -0
  21. package/package.json +42 -76
  22. package/src/TPStreamsPlayerViewNativeComponent.ts +9 -0
  23. package/src/index.tsx +9 -7
  24. package/android/generated/java/com/tpstreams/NativeTpstreamsSpec.java +0 -37
  25. package/android/generated/jni/CMakeLists.txt +0 -36
  26. package/android/generated/jni/RNTpstreamsSpec-generated.cpp +0 -32
  27. package/android/generated/jni/RNTpstreamsSpec.h +0 -31
  28. package/android/generated/jni/react/renderer/components/RNTpstreamsSpec/RNTpstreamsSpecJSI-generated.cpp +0 -28
  29. package/android/generated/jni/react/renderer/components/RNTpstreamsSpec/RNTpstreamsSpecJSI.h +0 -71
  30. package/android/libs/extracted-aar/META-INF/com/android/build/gradle/aar-metadata.properties +0 -4
  31. package/android/src/main/AndroidManifestNew.xml +0 -2
  32. package/android/src/main/java/com/tpstreams/FragmentModule.kt +0 -192
  33. package/android/src/main/java/com/tpstreams/PlayerFragment.kt +0 -226
  34. package/android/src/main/java/com/tpstreams/TpStreamsPlayerView.kt +0 -93
  35. package/android/src/main/java/com/tpstreams/TpStreamsPlayerViewManager.kt +0 -49
  36. package/android/src/main/java/com/tpstreams/TpstreamsModule.kt +0 -168
  37. package/android/src/main/res/layout/fragment_player.xml +0 -29
  38. package/android/src/main/res/xml/network_security_config.xml +0 -8
  39. package/ios/Tpstreams.h +0 -6
  40. package/ios/Tpstreams.mm +0 -18
  41. package/ios/generated/RNTpstreamsSpec/RNTpstreamsSpec-generated.mm +0 -39
  42. package/ios/generated/RNTpstreamsSpec/RNTpstreamsSpec.h +0 -63
  43. package/ios/generated/RNTpstreamsSpecJSI-generated.cpp +0 -28
  44. package/ios/generated/RNTpstreamsSpecJSI.h +0 -71
  45. package/lib/commonjs/NativeTpstreams.js +0 -9
  46. package/lib/commonjs/NativeTpstreams.js.map +0 -1
  47. package/lib/commonjs/index.js +0 -10
  48. package/lib/commonjs/index.js.map +0 -1
  49. package/lib/commonjs/types.js +0 -2
  50. package/lib/commonjs/types.js.map +0 -1
  51. package/lib/module/NativeTpstreams.js +0 -5
  52. package/lib/module/NativeTpstreams.js.map +0 -1
  53. package/lib/module/types.js +0 -2
  54. package/lib/module/types.js.map +0 -1
  55. package/lib/typescript/commonjs/package.json +0 -1
  56. package/lib/typescript/commonjs/src/NativeTpstreams.d.ts +0 -7
  57. package/lib/typescript/commonjs/src/NativeTpstreams.d.ts.map +0 -1
  58. package/lib/typescript/commonjs/src/index.d.ts +0 -5
  59. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  60. package/lib/typescript/commonjs/src/types.d.ts +0 -10
  61. package/lib/typescript/commonjs/src/types.d.ts.map +0 -1
  62. package/lib/typescript/module/src/NativeTpstreams.d.ts +0 -7
  63. package/lib/typescript/module/src/NativeTpstreams.d.ts.map +0 -1
  64. package/lib/typescript/module/src/index.d.ts +0 -5
  65. package/lib/typescript/module/src/index.d.ts.map +0 -1
  66. package/lib/typescript/module/src/types.d.ts +0 -10
  67. package/lib/typescript/module/src/types.d.ts.map +0 -1
  68. package/react-native.config.js +0 -12
  69. package/src/NativeTpstreams.ts +0 -8
  70. package/src/types.ts +0 -9
  71. /package/lib/{typescript/module → module}/package.json +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Bharath
3
+ Copyright (c) 2025 Testpress
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
6
6
  in the Software without restriction, including without limitation the rights
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # react-native-tpstreams
2
2
 
3
- Video Component for TPStreams
3
+ Video player component for TPStreams
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,436 +8,38 @@ Video Component for TPStreams
8
8
  npm install react-native-tpstreams
9
9
  ```
10
10
 
11
- ### Initializing TPStreams SDK
11
+ ## Usage
12
12
 
13
- First, import the package:
14
-
15
- ```javascript
16
- import { NativeModules } from 'react-native';
17
- const { Tpstreams } = NativeModules;
18
- ```
19
-
20
- Next, initialize the SDK with your organization ID:
21
-
22
- ```javascript
23
- Tpstreams.initializeTPSPlayer("YOUR_ORGANIZATION_ID");
24
- ```
25
-
26
- Make sure to replace `YOUR_ORGANIZATION_ID` with your actual organization ID. This should be called at the entry point of your application to ensure proper initialization.
27
-
28
- ## Play a Video
29
-
30
- To play a video using the TPStreams Player SDK, use the `TpStreamsPlayerView` component:
31
-
32
- ```javascript
33
- import React, { useState } from 'react';
34
- import { View, StyleSheet } from 'react-native';
35
- import TpStreamsPlayerView from 'react-native-tpstreams';
36
-
37
- const App = () => {
38
- const [playerProps] = useState({
39
- videoId: 'ASSET_ID',
40
- accessToken: 'ACCESS_TOKEN',
41
- enableDownload: false,
42
- autoPlay: true,
43
- startAt: 0,
44
- offlineLicenseExpireTime: 15,
45
- style: { width: '100%', height: 300 },
46
- });
47
-
48
- return (
49
- <View style={styles.container}>
50
- <TpStreamsPlayerView {...playerProps} />
51
- </View>
52
- );
53
- };
54
-
55
- const styles = StyleSheet.create({
56
- container: {
57
- flex: 1,
58
- justifyContent: 'center',
59
- alignItems: 'center',
60
- },
61
- });
62
-
63
- export default App;
64
- ```
65
-
66
- Replace `ASSET_ID` and `ACCESS_TOKEN` with the actual assetId and accessToken of the video you wish to play.
67
-
68
- ## Player Props
69
- The player component accepts the following props:
70
-
71
- | Prop | Type | Required | Default | Description |
72
- |--------------------------|---------|----------|---------|--------------------------------------------------------|
73
- | `videoId` | string | Yes | - | The unique identifier of the video asset. |
74
- | `accessToken` | string | Yes | - | The authentication token required to access the video. |
75
- | `enableDownload` | boolean | No | `true` | Enables or disables video download. |
76
- | `autoPlay` | boolean | No | `true` | Controls whether the video should start playing automatically. |
77
- | `startAt` | number | No | `0` | Start the video from a particular time (in seconds). |
78
- | `offlineLicenseExpireTime` | number | No | `1296000(15 days in seconds)` | DRM license expiration time in seconds. |
79
- | `style` | object | No | `{ width: '100%', height: 300 }` | Defines the player’s width and height. |
80
-
81
- # Player Methods
82
-
83
- To use the `Tpstreams` module, first import `NativeModules` from `react-native` and get the `Tpstreams` instance:
84
-
85
- ```js
86
- import { NativeModules } from 'react-native';
87
- const { Tpstreams } = NativeModules;
88
- ```
89
-
90
- The `Tpstreams` module provides several methods to control video playback and manage player states. Below is a detailed explanation of each method:
91
-
92
- ## Play
93
-
94
- ```js
95
- Tpstreams.play();
96
- ```
97
-
98
- Starts video playback. Call this method when you want the video to start playing or resume after being paused.
99
-
100
- ## Pause
101
-
102
- ```js
103
- Tpstreams.pause();
104
- ```
105
-
106
- Pauses video playback, allowing it to be resumed later from the same position.
107
-
108
- ## Seek To
109
-
110
- ```js
111
- Tpstreams.seekTo(position: number);
112
- ```
113
-
114
- Seeks to a specific position in the video (in milliseconds).
115
-
116
- **Example Usage:**
117
-
118
- ```js
119
- Tpstreams.seekTo(10000); // Jump to the 10-second mark
120
- ```
121
-
122
- ## Get Current Time
123
-
124
- ```js
125
- Tpstreams.getCurrentTime().then(console.log);
126
- ```
127
-
128
- Gets the current playback position of the video (in milliseconds). Returns a promise that resolves with the current time.
129
-
130
- ## Get Duration
131
-
132
- ```js
133
- Tpstreams.getDuration().then(console.log);
134
- ```
135
-
136
- Retrieves the total duration of the currently loaded video (in milliseconds). Returns a promise that resolves with the total duration.
137
-
138
- ## Get Buffered Time
139
-
140
- ```js
141
- Tpstreams.getBufferedTime().then(console.log);
142
- ```
143
-
144
- Gets the amount of video data that has been buffered (in milliseconds). Returns a promise that resolves with the buffered time.
145
-
146
- ## Get Playback State
147
-
148
- ```js
149
- Tpstreams.getPlaybackState().then(console.log);
150
- ```
151
-
152
- Gets the current playback state of the player (e.g., `playing`, `paused`, `buffering`). Returns a promise that resolves with the state.
153
-
154
- ## Get Play When Ready
155
-
156
- ```js
157
- Tpstreams.getPlayWhenReady().then(console.log);
158
- ```
159
-
160
- Checks if the player is set to start playback automatically. Returns a promise that resolves with a boolean value.
161
-
162
- ## Set Play When Ready
163
-
164
- ```js
165
- Tpstreams.setPlayWhenReady(true); // Enable autoplay
166
- ```
167
-
168
- Controls whether the player should start playback automatically when loaded.
169
-
170
- ## Get Playback Speed
171
-
172
- ```js
173
- Tpstreams.getPlaybackSpeed().then(console.log);
174
- ```
175
-
176
- Gets the current playback speed of the video. Returns a promise that resolves with the speed value.
177
-
178
- ## Set Playback Speed
179
-
180
- ```js
181
- Tpstreams.setPlaybackSpeed(1.5); // Play at 1.5x speed
182
- ```
183
-
184
- Changes the playback speed of the video.
185
-
186
- ## Release
187
-
188
- ```js
189
- Tpstreams.release();
190
- ```
191
-
192
- Releases the player resources, stopping playback and hiding the player UI. Once called, the player cannot be used again unless reinitialized.
193
-
194
-
195
- # Player Events
196
-
197
- `Tpstreams` provides event listeners to handle various player events. Below are the available events and how to use them:
198
-
199
- ## Listening to Events
200
-
201
- To subscribe to player events, use the `NativeEventEmitter` from `react-native` with `TpstreamsModule`:
13
+ Initialize TPStreams with your organization ID:
202
14
 
203
15
  ```js
204
- import { NativeEventEmitter, NativeModules } from 'react-native';
16
+ import { TPStreams } from "react-native-tpstreams";
205
17
 
206
- const { Tpstreams } = NativeModules;
207
- const eventEmitter = new NativeEventEmitter(Tpstreams);
208
-
209
- const subscription = eventEmitter.addListener('onPlaybackStateChanged', (state) => {
210
- console.log('Playback State Changed:', state);
211
- });
212
-
213
- // Remember to remove the listener when unmounting
214
- subscription.remove();
18
+ // Initialize with your organization ID
19
+ TPStreams.initialize('YOUR_ORGANIZATION_ID');
215
20
  ```
216
21
 
217
- ## Available Events
218
-
219
- ### onPlaybackStateChanged
220
- This event notifies us when the player's playback state changes:
221
-
222
- | State | Value | Description |
223
- |--------|-------|------------|
224
- | `STATE_IDLE` | `1` | The player is idle and not ready to play. |
225
- | `STATE_BUFFERING` | `2` | The player is buffering (waiting for enough data). |
226
- | `STATE_READY` | `3` | The player is ready to play. |
227
- | `STATE_ENDED` | `4` | The playback has finished. |
228
-
22
+ Then use the player component:
229
23
 
230
24
  ```js
231
- eventEmitter.addListener('onPlaybackStateChanged', (state) => {
232
- console.log('Playback State:', state);
233
- });
234
- ```
25
+ import { TPStreamsPlayerView } from "react-native-tpstreams";
235
26
 
236
- ### onAccessTokenExpired
237
- Triggered when the access token expires (requires refresh).
238
-
239
- ```js
240
- eventEmitter.addListener('onAccessTokenExpired', async () => {
241
- console.log('Access token expired, fetching a new one...');
242
-
243
- const newToken = await fetchNewAccessToken(); // Fetch the new token from your API
244
- Tpstreams.setNewAccessToken(newToken);
245
- });
27
+ // Use the player component where needed
28
+ <TPStreamsPlayerView
29
+ videoId="YOUR_VIDEO_ID"
30
+ accessToken="YOUR_ACCESS_TOKEN"
31
+ style={{ width: '100%', height: 300 }}
32
+ />
246
33
  ```
247
34
 
248
- ### onMarkerCallback
249
- Triggered when a marker (timestamp) is reached during playback.
35
+ ## Contributing
250
36
 
251
- ```js
252
- eventEmitter.addListener('onMarkerCallback', (marker) => {
253
- console.log('Marker reached:', marker);
254
- });
255
- ```
256
-
257
- ### onDeviceInfoChanged
258
- Triggered when the device information changes.
259
-
260
- ```js
261
- eventEmitter.addListener('onDeviceInfoChanged', (info) => {
262
- console.log('Device info changed:', info);
263
- });
264
- ```
37
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
265
38
 
266
- ### onFullScreenChanged
267
- Triggered when the fullscreen mode changes.
39
+ ## License
268
40
 
269
- ```js
270
- eventEmitter.addListener('onFullScreenChanged', (isFullscreen) => {
271
- console.log('Fullscreen mode:', isFullscreen);
272
- });
273
- ```
274
-
275
- ### onIsLoadingChanged
276
- - `true`: The player is currently loading or buffering new data from the network.
277
- - `false`: The player has sufficient buffered content and can play without interruption.
278
-
279
- ```js
280
- eventEmitter.addListener('onIsLoadingChanged', (isLoading) => {
281
- console.log('Loading state changed:', isLoading);
282
- });
283
- ```
41
+ MIT
284
42
 
285
- ### onIsPlayingChanged
286
- Triggered when the player’s playing state changes.
287
-
288
- ```js
289
- eventEmitter.addListener('onIsPlayingChanged', (isPlaying) => {
290
- console.log('Playing state:', isPlaying);
291
- });
292
- ```
293
-
294
- ### onPlayerError
295
- Triggered when the player encounters an error.
296
-
297
- ```js
298
- eventEmitter.addListener('onPlayerError', (error) => {
299
- console.log('Player Error:', error);
300
- });
301
- ```
302
-
303
- ### onSeekBackIncrementChanged
304
- Triggered when the seek-back increment value changes.
305
-
306
- ```js
307
- eventEmitter.addListener('onSeekBackIncrementChanged', (value) => {
308
- console.log('Seek back increment changed:', value);
309
- });
310
- ```
311
-
312
- ### onSeekForwardIncrementChanged
313
- Triggered when the seek-forward increment value changes.
314
-
315
- ```js
316
- eventEmitter.addListener('onSeekForwardIncrementChanged', (value) => {
317
- console.log('Seek forward increment changed:', value);
318
- });
319
- ```
320
-
321
- ### onTimelineChanged
322
- Triggered when the timeline of the player changes.
323
-
324
- ```js
325
- eventEmitter.addListener('onTimelineChanged', (timeline) => {
326
- console.log('Timeline changed:', timeline);
327
- });
328
- ```
329
-
330
- ### onTracksChanged
331
- Triggered when the available tracks change (e.g., audio/video/subtitles).
332
-
333
- ```js
334
- eventEmitter.addListener('onTracksChanged', (tracks) => {
335
- console.log('Tracks changed:', tracks);
336
- });
337
- ```
338
-
339
- # Download Module
340
-
341
- The `Download Module` in `Tpstreams` allows users to manage offline video downloads efficiently. This includes observing download progress, pausing, resuming, canceling, and deleting downloads.
342
-
343
- ## Observing Download Data
344
-
345
- To start observing the download data, call the `observeDownloadData` method from `FragmentModule`.
346
-
347
- ```js
348
- import { NativeModules, DeviceEventEmitter } from 'react-native';
349
-
350
- const { FragmentModule } = NativeModules;
351
- FragmentModule.observeDownloadData();
352
- ```
353
-
354
- Once initialized, the module will emit events whenever the download data changes.
355
-
356
- ## Listening to Download Events
357
-
358
- To listen for download state changes, use `DeviceEventEmitter`:
359
-
360
- ```js
361
- const subscription = DeviceEventEmitter.addListener(
362
- 'onDownloadDataChanged',
363
- (event) => {
364
- console.log('Download data updated:', event.assets);
365
- }
366
- );
367
-
368
- // Remember to remove the listener when unmounting
369
- subscription.remove();
370
- ```
371
-
372
- ## Managing Downloads
373
-
374
- ### Pause Download
375
- Pauses an active download.
376
-
377
- ```js
378
- FragmentModule.pauseDownload(videoId);
379
- ```
380
-
381
- ### Resume Download
382
- Resumes a paused download.
383
-
384
- ```js
385
- FragmentModule.resumeDownload(videoId);
386
- ```
387
-
388
- ### Cancel Download
389
- Cancels an ongoing download.
390
-
391
- ```js
392
- FragmentModule.cancelDownload(videoId);
393
- ```
394
-
395
- ### Delete Download
396
- Deletes a completed download from storage.
397
-
398
- ```js
399
- FragmentModule.deleteDownload(videoId);
400
- ```
401
-
402
- ## Rendering a Download List
403
-
404
- Below is a sample implementation of a download list UI using `FlatList` in React Native:
405
-
406
- ```js
407
- import React, { useState, useEffect } from 'react';
408
- import { SafeAreaView, Text, FlatList, View, Button, DeviceEventEmitter } from 'react-native';
409
- import { NativeModules } from 'react-native';
410
-
411
- const { FragmentModule } = NativeModules;
412
-
413
- const DownloadListScreen = () => {
414
- const [downloads, setDownloads] = useState([]);
415
-
416
- useEffect(() => {
417
- FragmentModule.observeDownloadData();
418
- const subscription = DeviceEventEmitter.addListener('onDownloadDataChanged', (event) => {
419
- setDownloads(event.assets);
420
- });
421
- return () => subscription.remove();
422
- }, []);
423
-
424
- const renderItem = ({ item }) => (
425
- <View>
426
- <Text>{item.title} - {item.percentage}%</Text>
427
- {item.status === 'DOWNLOADING' && <Button title="Pause" onPress={() => FragmentModule.pauseDownload(item.videoId)} />}
428
- {item.status === 'COMPLETE' && <Button title="Delete" onPress={() => FragmentModule.deleteDownload(item.videoId)} />}
429
- {item.status === 'PAUSED' && <Button title="Resume" onPress={() => FragmentModule.resumeDownload(item.videoId)} />}
430
- </View>
431
- );
432
-
433
- return (
434
- <SafeAreaView>
435
- <FlatList data={downloads} keyExtractor={(item) => item.videoId} renderItem={renderItem} />
436
- </SafeAreaView>
437
- );
438
- };
439
-
440
- export default DownloadListScreen;
441
- ```
43
+ ---
442
44
 
443
- This component observes download events and dynamically updates the list with buttons for user interactions.
45
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
package/Tpstreams.podspec CHANGED
@@ -1,7 +1,6 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
4
 
6
5
  Pod::Spec.new do |s|
7
6
  s.name = "Tpstreams"
@@ -12,31 +11,10 @@ Pod::Spec.new do |s|
12
11
  s.authors = package["author"]
13
12
 
14
13
  s.platforms = { :ios => min_ios_version_supported }
15
- s.source = { :git => "https://github.com/testpress/react-native-player-sdk.git", :tag => "#{s.version}" }
14
+ s.source = { :git => "https://github.com/testpress/react-native-tpstreams.git", :tag => "#{s.version}" }
16
15
 
17
16
  s.source_files = "ios/**/*.{h,m,mm,cpp}"
18
- s.private_header_files = "ios/generated/**/*.h"
17
+ s.private_header_files = "ios/**/*.h"
19
18
 
20
- # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
- # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22
- if respond_to?(:install_modules_dependencies, true)
23
- install_modules_dependencies(s)
24
- else
25
- s.dependency "React-Core"
26
-
27
- # Don't install the dependencies when we run `pod install` in the old architecture.
28
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
30
- s.pod_target_xcconfig = {
31
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
32
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
33
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
34
- }
35
- s.dependency "React-Codegen"
36
- s.dependency "RCT-Folly"
37
- s.dependency "RCTRequired"
38
- s.dependency "RCTTypeSafety"
39
- s.dependency "ReactCommon/turbomodule/core"
40
- end
41
- end
19
+ install_modules_dependencies(s)
42
20
  end
@@ -4,6 +4,7 @@ buildscript {
4
4
  }
5
5
 
6
6
  repositories {
7
+ mavenLocal()
7
8
  google()
8
9
  mavenCentral()
9
10
  }
@@ -20,53 +21,28 @@ rootProject.allprojects {
20
21
  mavenCentral() // Ensure this line is here
21
22
  google()
22
23
  maven {
23
- url "https://github.com/testpress/maven/raw/main/repo"
24
+ url "https://github.com/testpress/TPStreamsAndroidPlayerMaven/raw/main/repo"
24
25
  }
25
26
  }
26
27
  }
27
28
 
28
-
29
- def isNewArchitectureEnabled() {
30
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
31
- }
32
-
33
29
  apply plugin: "com.android.library"
34
30
  apply plugin: "kotlin-android"
35
31
 
36
- if (isNewArchitectureEnabled()) {
37
- apply plugin: "com.facebook.react"
38
- }
32
+ apply plugin: "com.facebook.react"
39
33
 
40
34
  def getExtOrIntegerDefault(name) {
41
35
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Tpstreams_" + name]).toInteger()
42
36
  }
43
37
 
44
- def supportsNamespace() {
45
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
46
- def major = parsed[0].toInteger()
47
- def minor = parsed[1].toInteger()
48
-
49
- // Namespace support was added in 7.3.0
50
- return (major == 7 && minor >= 3) || major >= 8
51
- }
52
-
53
38
  android {
54
- if (supportsNamespace()) {
55
- namespace "com.tpstreams"
56
-
57
- sourceSets {
58
- main {
59
- manifest.srcFile "src/main/AndroidManifestNew.xml"
60
- }
61
- }
62
- }
39
+ namespace "com.tpstreams"
63
40
 
64
41
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
65
42
 
66
43
  defaultConfig {
67
44
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
68
45
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
69
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
70
46
  }
71
47
 
72
48
  buildFeatures {
@@ -90,18 +66,16 @@ android {
90
66
 
91
67
  sourceSets {
92
68
  main {
93
- if (isNewArchitectureEnabled()) {
94
- java.srcDirs += [
95
- "generated/java",
96
- "generated/jni"
97
- ]
98
- }
69
+ java.srcDirs += [
70
+ "generated/java",
71
+ "generated/jni"
72
+ ]
99
73
  }
100
74
  }
101
75
  }
102
76
 
103
77
  repositories {
104
- mavenCentral()
78
+ mavenLocal()
105
79
  google()
106
80
  }
107
81
 
@@ -110,13 +84,11 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
110
84
  dependencies {
111
85
  implementation "com.facebook.react:react-android"
112
86
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
113
- implementation "com.tpstreams.player:player:3.1.6"
87
+ implementation "com.tpstreams:tpstreams-player:0.0.1"
114
88
  }
115
89
 
116
- if (isNewArchitectureEnabled()) {
117
- react {
118
- jsRootDir = file("../src/")
119
- libraryName = "Tpstreams"
120
- codegenJavaPackageName = "com.tpstreams"
121
- }
90
+ react {
91
+ jsRootDir = file("../src/")
92
+ libraryName = "TpstreamsView"
93
+ codegenJavaPackageName = "com.tpstreams"
122
94
  }
@@ -1,4 +1,2 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.tpstreams">
3
- <application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:networkSecurityConfig="@xml/network_security_config"></application>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
4
2
  </manifest>
@@ -0,0 +1,18 @@
1
+ package com.tpstreams
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.tpstreams.player.TPStreamsPlayer
7
+
8
+ class TPStreamsRNModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
9
+
10
+ override fun getName(): String {
11
+ return "TPStreams"
12
+ }
13
+
14
+ @ReactMethod
15
+ fun initialize(organizationId: String) {
16
+ TPStreamsPlayer.init(organizationId)
17
+ }
18
+ }
@@ -4,13 +4,18 @@ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
+ import java.util.ArrayList
7
8
 
8
- class TpstreamsPackage : ReactPackage {
9
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
- return listOf(TpstreamsModule(reactContext), FragmentModule(reactContext))
9
+ class TPStreamsRNPackage : ReactPackage {
10
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
11
+ val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
12
+ viewManagers.add(TPStreamsRNPlayerViewManager())
13
+ return viewManagers
11
14
  }
12
15
 
13
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
14
- return listOf(TpStreamsPlayerViewManager())
16
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
17
+ val modules: MutableList<NativeModule> = ArrayList()
18
+ modules.add(TPStreamsRNModule(reactContext))
19
+ return modules
15
20
  }
16
21
  }