react-native-tpstreams 0.1.10 → 0.1.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 +16 -9
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/tpstreams/PlayerFragment.kt +2 -2
- package/android/src/main/java/com/tpstreams/TpStreamsPlayerView.kt +2 -2
- package/lib/typescript/commonjs/src/types.d.ts +2 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +2 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/types.ts +2 -0
package/README.md
CHANGED
|
@@ -40,6 +40,8 @@ const App = () => {
|
|
|
40
40
|
accessToken: 'ACCESS_TOKEN',
|
|
41
41
|
enableDownload: false,
|
|
42
42
|
autoPlay: true,
|
|
43
|
+
startAt: 0,
|
|
44
|
+
offlineLicenseExpireTime: 15,
|
|
43
45
|
style: { width: '100%', height: 300 },
|
|
44
46
|
});
|
|
45
47
|
|
|
@@ -66,13 +68,15 @@ Replace `ASSET_ID` and `ACCESS_TOKEN` with the actual assetId and accessToken of
|
|
|
66
68
|
## Player Props
|
|
67
69
|
The player component accepts the following props:
|
|
68
70
|
|
|
69
|
-
| Prop
|
|
70
|
-
|
|
71
|
-
| `videoId`
|
|
72
|
-
| `accessToken`
|
|
73
|
-
| `enableDownload`
|
|
74
|
-
| `autoPlay`
|
|
75
|
-
| `
|
|
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 | `15` | DRM license expiration time in days. |
|
|
79
|
+
| `style` | object | No | `{ width: '100%', height: 300 }` | Defines the player’s width and height. |
|
|
76
80
|
|
|
77
81
|
# Player Methods
|
|
78
82
|
|
|
@@ -225,8 +229,11 @@ eventEmitter.addListener('onPlaybackStateChanged', (state) => {
|
|
|
225
229
|
Triggered when the access token expires (requires refresh).
|
|
226
230
|
|
|
227
231
|
```js
|
|
228
|
-
eventEmitter.addListener('onAccessTokenExpired', () => {
|
|
229
|
-
console.log('Access token expired,
|
|
232
|
+
eventEmitter.addListener('onAccessTokenExpired', async () => {
|
|
233
|
+
console.log('Access token expired, fetching a new one...');
|
|
234
|
+
|
|
235
|
+
const newToken = await fetchNewAccessToken(); // Fetch the new token from your API
|
|
236
|
+
Tpstreams.setNewAccessToken(newToken);
|
|
230
237
|
});
|
|
231
238
|
```
|
|
232
239
|
|
package/android/build.gradle
CHANGED
|
@@ -110,7 +110,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
110
110
|
dependencies {
|
|
111
111
|
implementation "com.facebook.react:react-android"
|
|
112
112
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
113
|
-
implementation "com.tpstreams.player:player:3.1.
|
|
113
|
+
implementation "com.tpstreams.player:player:3.1.6"
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
if (isNewArchitectureEnabled()) {
|
|
@@ -31,7 +31,7 @@ class PlayerFragment : Fragment() {
|
|
|
31
31
|
private var enableDownloadSupport :Boolean = true
|
|
32
32
|
private var setAutoPlay :Boolean = true
|
|
33
33
|
private var startAt :Int = 0
|
|
34
|
-
private var offlineLicenseExpireTime :Int = 15
|
|
34
|
+
private var offlineLicenseExpireTime :Int = 60 * 60 * 24 * 15 //15 days
|
|
35
35
|
|
|
36
36
|
private var accessTokenCallback : onAccessTokenCallbase? = null
|
|
37
37
|
|
|
@@ -48,7 +48,7 @@ class PlayerFragment : Fragment() {
|
|
|
48
48
|
enableDownloadSupport = bundle.getBoolean("ENABLE_DOWNLOAD_SUPPORT", true)
|
|
49
49
|
setAutoPlay = bundle.getBoolean("AUTO_PLAY", true)
|
|
50
50
|
startAt = bundle.getInt("START_AT", 0)
|
|
51
|
-
offlineLicenseExpireTime = bundle.getInt("OFFLINE_LICENSE_EXPIRE_TIME",
|
|
51
|
+
offlineLicenseExpireTime = bundle.getInt("OFFLINE_LICENSE_EXPIRE_TIME", offlineLicenseExpireTime)
|
|
52
52
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -18,7 +18,7 @@ class TpStreamsPlayerView @JvmOverloads constructor(
|
|
|
18
18
|
private var enableDownload: Boolean = true
|
|
19
19
|
private var autoPlay :Boolean = true
|
|
20
20
|
private var startAt :Int = 0
|
|
21
|
-
private var offlineLicenseExpireTime :Int = 15
|
|
21
|
+
private var offlineLicenseExpireTime :Int = 60 * 60 * 24 * 15
|
|
22
22
|
private var fragmentModule: FragmentModule? = null
|
|
23
23
|
|
|
24
24
|
private val job = SupervisorJob()
|
|
@@ -62,7 +62,7 @@ class TpStreamsPlayerView @JvmOverloads constructor(
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
fun setOfflineLicenseExpireTime(offlineLicenseExpireTime: Int?) {
|
|
65
|
-
this.offlineLicenseExpireTime = offlineLicenseExpireTime ?: 15
|
|
65
|
+
this.offlineLicenseExpireTime = offlineLicenseExpireTime ?: 60 * 60 * 24 * 15
|
|
66
66
|
updateFragment()
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,cAAc,EAAE,SAAS,CAAC;CAC1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,cAAc,EAAE,SAAS,CAAC;CAC1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,cAAc,EAAE,SAAS,CAAC;CAC1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,cAAc,EAAE,SAAS,CAAC;CAC1C,CAAC"}
|
package/package.json
CHANGED