@jwplayer/jwplayer-react-native 1.1.3 → 1.3.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 (36) hide show
  1. package/README.md +114 -21
  2. package/RNJWPlayer.podspec +1 -1
  3. package/android/build.gradle +14 -1
  4. package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerModule.java +27 -0
  5. package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerView.java +373 -204
  6. package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerViewManager.java +16 -0
  7. package/android/src/main/java/com/jwplayer/rnjwplayer/Util.java +13 -1
  8. package/badges/version.svg +1 -1
  9. package/docs/CONFIG-REFERENCE.md +747 -0
  10. package/docs/MIGRATION-GUIDE.md +617 -0
  11. package/docs/PLATFORM-DIFFERENCES.md +693 -0
  12. package/docs/props.md +15 -3
  13. package/index.d.ts +225 -216
  14. package/index.js +34 -0
  15. package/ios/RNJWPlayer/RNJWPlayerView.swift +365 -10
  16. package/ios/RNJWPlayer/RNJWPlayerViewController.swift +45 -16
  17. package/ios/RNJWPlayer/RNJWPlayerViewManager.m +2 -0
  18. package/ios/RNJWPlayer/RNJWPlayerViewManager.swift +13 -0
  19. package/package.json +2 -2
  20. package/types/advertising.d.ts +514 -0
  21. package/types/index.d.ts +21 -0
  22. package/types/legacy.d.ts +82 -0
  23. package/types/platform-specific.d.ts +641 -0
  24. package/types/playlist.d.ts +410 -0
  25. package/types/unified-config.d.ts +591 -0
  26. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  27. package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
  28. package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
  29. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  30. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  31. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  32. package/android/.gradle/8.9/gc.properties +0 -0
  33. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  34. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  35. package/android/.gradle/vcs-1/gc.properties +0 -0
  36. package/docs/types.md +0 -254
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Version](/badges/version.svg)](https://github.com/jwplayer/jwplayer-react-native) [![NPM version](https://img.shields.io/npm/v/%40jwplayer%2Fjwplayer-react-native)](https://www.npmjs.com/package/@jwplayer/jwplayer-react-native) [![License](/badges/license.svg)](/LICENSE)
4
4
 
5
- ⚠️ This **README** is for `jwplayer-react-native` version `1.0.0` and higher, for previous versions from the original author, [Chaim Paneth](https://github.com/chaimPaneth) via [Orthodox Union](https://www.ou.org/), see [react-native-jw-media-player](https://github.com/chaimPaneth/react-native-jw-media-player). Beginning with version `0.2.0`, this library uses [JWP's `JWPlayerKit ` (iOS)]((https://developer.jwplayer.com/jwplayer/docs/ios-get-started)) and [SDK 4 (Android)]((https://developer.jwplayer.com/jwplayer/docs/android-get-started)).
5
+ ⚠️ This **README** is for `jwplayer-react-native` version `1.0.0` and higher, for previous versions from the original author, [Chaim Paneth](https://github.com/chaimPaneth) via [Orthodox Union](https://www.ou.org/), see [react-native-jw-media-player](https://github.com/chaimPaneth/react-native-jw-media-player). Beginning with version `0.2.0`, this library uses [JWX's `JWPlayerKit ` (iOS)]((https://developer.jwplayer.com/jwplayer/docs/ios-get-started)) and [SDK 4 (Android)]((https://developer.jwplayer.com/jwplayer/docs/android-get-started)).
6
6
 
7
7
  <br />
8
8
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  <br />
12
12
 
13
- The `jwplayer-react-native` library is a bridge that enables using the native JWP Android and iOS SDKs in React Native applications.
13
+ The `jwplayer-react-native` library is a bridge that enables using the native JWX Android and iOS SDKs in React Native applications.
14
14
 
15
15
  <img width="200" alt="sample" src="./images/1.png"> <img width="200" alt="sample" src="./images/2.png"> <img width="200" alt="sample" src="./images/3.png">
16
16
 
@@ -19,8 +19,8 @@ The `jwplayer-react-native` library is a bridge that enables using the native JW
19
19
  ## Prerequisites
20
20
 
21
21
  Before installing and using the library, you need the following items:
22
- - JWP [Account](https://jwplayer.com/pricing/)
23
- - JWP License Key ([Android](https://docs.jwplayer.com/players/docs/android-overview#requirements) | [iOS](https://docs.jwplayer.com/players/docs/ios-overview#requirements))
22
+ - JWX [Account](https://jwplayer.com/pricing/)
23
+ - JWX License Key ([Android](https://docs.jwplayer.com/players/docs/android-overview#requirements) | [iOS](https://docs.jwplayer.com/players/docs/ios-overview#requirements))
24
24
  - [React Native App](https://reactnative.dev/docs/getting-started)
25
25
  - Package Manager ([npm](https://nodejs.org/en/download) | [yarn](https://yarnpkg.com/getting-started/install) )
26
26
 
@@ -38,7 +38,7 @@ Follow these steps to add the library to your Android project:
38
38
 
39
39
  yarn: `yarn add @jwplayer/jwplayer-react-native`
40
40
 
41
- 2. In **android/build.gradle**, add the JWP Maven repository inside the `allprojects` block.
41
+ 2. In **android/build.gradle**, add the JWX Maven repository inside the `allprojects` block.
42
42
 
43
43
  ```groovy
44
44
  allprojects {
@@ -49,7 +49,7 @@ Follow these steps to add the library to your Android project:
49
49
  }
50
50
  ```
51
51
 
52
- For more details and guidance regarding configuration and requirements, see the [JWP Android SDK documentation](https://docs.jwplayer.com/players/docs/android-overview#requirements).
52
+ For more details and guidance regarding configuration and requirements, see the [JWX Android SDK documentation](https://docs.jwplayer.com/players/docs/android-overview#requirements).
53
53
 
54
54
  <br />
55
55
 
@@ -72,13 +72,13 @@ Follow these steps to add the library to your iOS project:
72
72
  pod install
73
73
  ```
74
74
 
75
- For more details and guidance regarding configuration and requirements, see the [JWP iOS SDK documentation](https://docs.jwplayer.com/players/docs/ios-overview#requirements).
75
+ For more details and guidance regarding configuration and requirements, see the [JWX iOS SDK documentation](https://docs.jwplayer.com/players/docs/ios-overview#requirements).
76
76
 
77
77
  <br /><br />
78
78
 
79
79
  ## Usage
80
80
 
81
- The following example shows how you can enhance your React Native application by seamlessly integrating the multimedia playback functionalities of the JWP mobile SDKs.
81
+ The following example shows how you can enhance your React Native application by seamlessly integrating the multimedia playback functionalities of the JWX mobile SDKs.
82
82
 
83
83
  Follow these steps to configure the media playback experience in your app:
84
84
 
@@ -190,7 +190,7 @@ Follow these steps to configure the media playback experience in your app:
190
190
  ```
191
191
 
192
192
 
193
- 2. Define `config.license` with your Android or iOS JWP license key.
193
+ 2. Define `config.license` with your Android or iOS JWX license key.
194
194
  3. Define `config.playlist` with the media to play in the player.
195
195
  4. (Optional) Define the other values of the `config` prop.
196
196
 
@@ -222,7 +222,7 @@ Follow these steps to run the example project:
222
222
  pod install
223
223
  ```
224
224
  4. In Xcode,open **RNJWPlayer.xcworkspace**.
225
- 5. In **App.js**, within the `config` prop, add your JWP SDK license key.
225
+ 5. In **App.js**, within the `config` prop, add your JWX SDK license key.
226
226
  6. Build and run the app for your preferred platform.
227
227
  ```
228
228
  yarn android
@@ -240,6 +240,68 @@ Follow these steps to run the example project:
240
240
 
241
241
  <br /><br />
242
242
 
243
+ ## Configuration
244
+
245
+ The library now features a **unified configuration system** that provides consistent, type-safe configuration across both iOS and Android platforms.
246
+
247
+ ### 📚 Documentation
248
+
249
+ - **[Configuration Reference](./docs/CONFIG-REFERENCE.md)** - Complete guide to all configuration options with examples
250
+ - **[Platform Differences](./docs/PLATFORM-DIFFERENCES.md)** - Detailed comparison of iOS vs Android features
251
+ - **[Migration Guide](./docs/MIGRATION-GUIDE.md)** - Guide for upgrading to the unified type system
252
+ - **[Props Documentation](./docs/props.md)** - Component props reference
253
+
254
+ ### Quick Example
255
+
256
+ ```typescript
257
+ import JWPlayer, { JWPlayerConfig } from '@jwplayer/jwplayer-react-native';
258
+
259
+ const config: JWPlayerConfig = {
260
+ license: 'YOUR_LICENSE_KEY',
261
+ file: 'https://example.com/video.m3u8',
262
+ autostart: true,
263
+ advertising: {
264
+ client: 'dai',
265
+ imaDaiSettings: {
266
+ videoId: 'tears-of-steel',
267
+ cmsId: '2528370'
268
+ }
269
+ }
270
+ };
271
+
272
+ export default () => (
273
+ <JWPlayer config={config} style={{ flex: 1 }} />
274
+ );
275
+ ```
276
+
277
+ ### Configuration Modes
278
+
279
+ The library supports two configuration modes:
280
+
281
+ 1. **Modern Configuration (Recommended)**
282
+ - Uses the unified type system (`JWPlayerConfig`)
283
+ - Provides full type safety and IDE support
284
+ - Matches JW Player Delivery API format
285
+ - Clearly documents platform-specific features
286
+ - Example: See [TypeScript Example](./Example/app/jsx/screens/TypeScriptExample.tsx)
287
+
288
+ 2. **Legacy Configuration**
289
+ - Set `forceLegacyConfig={true}` in props
290
+ - Uses older builder patterns from previous versions
291
+ - Limited type safety and platform support
292
+ - Not recommended for new implementations
293
+ - Documentation: See [Legacy Readme](./docs/legacy_readme.md)
294
+
295
+ ### Key Features
296
+
297
+ - ✅ **Type Safety**: Full TypeScript support with autocomplete
298
+ - ✅ **Cross-Platform**: Single configuration works on both iOS and Android
299
+ - ✅ **Platform Annotations**: Clear documentation of platform-specific features
300
+ - ✅ **Backward Compatible**: Existing configurations continue to work
301
+ - ✅ **Well Documented**: Comprehensive guides for all features
302
+
303
+ <br /><br />
304
+
243
305
  ## Advanced Topics
244
306
 
245
307
  [Advertising](#advertising) | [Background Audio](#background-audio) | [Casting](#casting) | [DRM](#drm) | [Picture in Picture (PiP)](#picture-in-picture-pip) | [Styling](#styling)
@@ -252,9 +314,40 @@ Follow these steps to run the example project:
252
314
 
253
315
  #### Android Advertising
254
316
 
255
- Follow this step to set up advertising with IMA or DAI:
317
+ Follow these steps to set up advertising with IMA or DAI:
318
+
319
+ 1. In the **android/build.gradle** `ext{}` block, add `RNJWPlayerUseGoogleIMA = true`.
320
+
321
+ ```groovy
322
+ buildscript {
323
+ ext {
324
+ RNJWPlayerUseGoogleIMA = true
325
+ }
326
+ }
327
+ ```
328
+
329
+ This setting will add the following dependencies: `com.google.ads.interactivemedia.v3:interactivemedia:3.36.0` and `com.google.android.gms:play-services-ads-identifier:18.0.1`.
330
+
331
+ 2. **⚠️ REQUIRED: Enable desugaring in your app** (required for IMA SDK 3.37.0+):
332
+
333
+ In your **android/app/build.gradle**, add the following configuration:
334
+
335
+ ```groovy
336
+ android {
337
+ compileOptions {
338
+ sourceCompatibility JavaVersion.VERSION_1_8
339
+ targetCompatibility JavaVersion.VERSION_1_8
340
+ coreLibraryDesugaringEnabled true
341
+ }
342
+ }
343
+
344
+ dependencies {
345
+ // ... your other dependencies
346
+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
347
+ }
348
+ ```
256
349
 
257
- 1. In the **app/build.gradle** `ext{}`, add `RNJWPlayerUseGoogleIMA = true`. This setting will add the following dependencies: `com.google.ads.interactivemedia.v3:interactivemedia:3.31.0` and `com.google.android.gms:play-services-ads-identifier:18.0.1`.
350
+ > **Important**: The IMA SDK 3.37.0+ requires desugaring due to its transitive dependencies. While the `jwplayer-react-native` library configures desugaring internally, **Android requires that your consuming app also explicitly enable desugaring**. If you skip step 2, you will get build errors like "Dependency requires core library desugaring to be enabled". This is an Android Gradle requirement where both the library and the consuming app must opt-in to desugaring.
258
351
 
259
352
  <br />
260
353
 
@@ -314,7 +407,7 @@ Suppose you are **not** using the background audio service on Android. In that c
314
407
 
315
408
  [Android](#android-casting) | [iOS](#ios-casting) | [DRM Casting](#drm-casting)
316
409
 
317
- JWP enables casting by default with a casting button.
410
+ JWX enables casting by default with a casting button.
318
411
 
319
412
  <br />
320
413
 
@@ -380,7 +473,7 @@ Casting your DRM protected content requires some additional configuration and mo
380
473
 
381
474
  See our Android and iOS documentation about creating ([iOS](https://docs.jwplayer.com/players/docs/ios-create-a-custom-receiver) / [Android](https://docs.jwplayer.com/players/docs/android-create-a-custom-receiver)) and sending data ([iOS](https://docs.jwplayer.com/players/docs/ios-enable-casting-to-chromecast-devices#send-custom-data-to-a-custom-receiver) / [Android](https://docs.jwplayer.com/players/docs/android-enable-casting-to-chromecast-devices#send-custom-data-to-a-custom-receiver)) for more information.
382
475
 
383
- To send custom data to your receiver, use the `userInfo` prop and avoid using the reserved `sources` key, as the JWP SDK will append the DRM source information here for you to parse in your DRM enabled receiver.
476
+ To send custom data to your receiver, use the `userInfo` prop and avoid using the reserved `sources` key, as the JWX SDK will append the DRM source information here for you to parse in your DRM enabled receiver.
384
477
 
385
478
  <br /><br />
386
479
 
@@ -398,11 +491,11 @@ Only Widevine is supported.
398
491
 
399
492
  Follow these steps to enable DRM:
400
493
  1. Set up your Android app for [DRM playback](https://developer.jwplayer.com/jwplayer/docs/android-play-drm-protected-content).
401
- 2. Define `config.playlist` with the [JWP signed URL](https://docs.jwplayer.com/platform/docs/protection-studio-drm-generate-a-signed-content-url-for-drm-playback) of the media to play in the player.
494
+ 2. Define `config.playlist` with the [JWX signed URL](https://docs.jwplayer.com/platform/docs/protection-studio-drm-generate-a-signed-content-url-for-drm-playback) of the media to play in the player.
402
495
 
403
496
  *❗️DO NOT sign and store your API secerets from your application.❗️*
404
497
 
405
- If you use a different provider for DRM or this does not work for your use case, conforming to a similiar format as a JWP signed URL response is optimal, such as adding the `drm` field to the `sources` for a playlist item).
498
+ If you use a different provider for DRM or this does not work for your use case, conforming to a similiar format as a JWX signed URL response is optimal, such as adding the `drm` field to the `sources` for a playlist item).
406
499
 
407
500
  <br />
408
501
 
@@ -414,11 +507,11 @@ The below is currently not fully supported by the iOS SDK, so please refer to `E
414
507
 
415
508
  > Follow these steps to enable DRM:
416
509
  > 1. Set up your iOS app for [DRM playback](https://developer.jwplayer.com/jwplayer/docs/ios-play-drm-protected-content).
417
- > 2. Define `config.playlist` with the [JWP signed URL](https://docs.jwplayer.com/platform/docs/protection-studio-drm-generate-a-signed-content-url-for-drm-playback) of the media to play in the player.
510
+ > 2. Define `config.playlist` with the [JWX signed URL](https://docs.jwplayer.com/platform/docs/protection-studio-drm-generate-a-signed-content-url-for-drm-playback) of the media to play in the player.
418
511
  >
419
512
  > *❗️DO NOT sign and store your API secerets from your application.❗️*
420
513
  >
421
- If you use a different provider for DRM or this does not work for your use case, conforming to a similiar format as a JWP signed URL response is optimal, such as adding the `drm` field to the `sources` for a playlist item).
514
+ If you use a different provider for DRM or this does not work for your use case, conforming to a similiar format as a JWX signed URL response is optimal, such as adding the `drm` field to the `sources` for a playlist item).
422
515
 
423
516
  <br /><br />
424
517
 
@@ -446,7 +539,7 @@ If you use a different provider for DRM or this does not work for your use case,
446
539
 
447
540
  #### iOS PiP
448
541
 
449
- 1. Read and understand the requirements for PiP in the [iOS SDK](https://docs.jwplayer.com/players/docs/ios-invoke-picture-in-picture-playback). PiP mode is enabled by JWP for the `PlayerViewController`.
542
+ 1. Read and understand the requirements for PiP in the [iOS SDK](https://docs.jwplayer.com/players/docs/ios-invoke-picture-in-picture-playback). PiP mode is enabled by JWX for the `PlayerViewController`.
450
543
  2. (viewOnly:true only) Set the `pipEnabled` prop to `true`.
451
544
  3. (viewOnly:true only) Call `togglePIP()` to enable or disable PiP.
452
545
  4. Ensure [category](/docs//legacy_readme.md#audiosessioncategory) and/or [categoryOptions](/docs//legacy_readme.md#audiosessioncategoryoptions) prop(s) are set to define and configure your media. This is required to setup the audio session. If `category` is not defined but `pipEnabled` is set true, we default to the standard `playback` category to avoid crashing.
@@ -458,9 +551,9 @@ If you use a different provider for DRM or this does not work for your use case,
458
551
  [Android](#android-styling) | [iOS](#ios-styling)
459
552
 
460
553
  #### Android Styling
461
- The `styling` prop will not work when using the modern prop convention that matches the JWP Delivery API. Even when using the `forceLegacyConfig` prop, Android may not respect your choices.
554
+ The `styling` prop will not work with Android when using the modern configuration system. Android styling should be handled through XML resource overrides (see below).
462
555
 
463
- Android styling is best handled through overring JWP IDs in your apps resources files. See the documentation [here](https://docs.jwplayer.com/players/docs/android-styling-guide).
556
+ Android styling is best handled through overring JWX IDs in your apps resources files. See the documentation [here](https://docs.jwplayer.com/players/docs/android-styling-guide).
464
557
 
465
558
  A sample of overring a color via XML can be seen in this [colors file](Example/android/app/src/main/res/values/colors.xml). The color specified here is the default, but if you wish to change it, the color will be updated on the player.
466
559
 
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
12
12
  s.platform = :ios, "15.0"
13
13
  s.source = { :git => "https://github.com/jwplayer/jwplayer-react-native.git", :tag => "v#{s.version}" }
14
14
  s.source_files = "ios/RNJWPlayer/*.{h,m,swift}"
15
- s.dependency 'JWPlayerKit', '4.23.1'
15
+ s.dependency 'JWPlayerKit', '4.25.0'
16
16
  s.dependency 'React-Core'
17
17
  s.static_framework = true
18
18
  s.info_plist = {
@@ -39,6 +39,15 @@ android {
39
39
  }
40
40
  }
41
41
 
42
+ // Enable desugaring conditionally when IMA is used (required for IMA SDK 3.37.0+)
43
+ compileOptions {
44
+ sourceCompatibility JavaVersion.VERSION_1_8
45
+ targetCompatibility JavaVersion.VERSION_1_8
46
+ if (useIMA) {
47
+ coreLibraryDesugaringEnabled true
48
+ }
49
+ }
50
+
42
51
  buildTypes {
43
52
  debug {
44
53
  // Set the build config fields for the debug build type
@@ -73,7 +82,7 @@ allprojects {
73
82
  }
74
83
  }
75
84
 
76
- def jwPlayerVersion = "4.21.0"
85
+ def jwPlayerVersion = "4.24.0"
77
86
  def exoplayerVersion = "2.18.7" // Deprecated. Use Media3 when targeting JW SDK > 4.16.0
78
87
  def media3ExoVersion = "1.4.1"
79
88
 
@@ -91,6 +100,10 @@ dependencies {
91
100
  if (useIMA) {
92
101
  implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.36.0'
93
102
  implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
103
+ // Core library desugaring (required for IMA SDK 3.37.0+)
104
+ // Using version 2.1.5 as recommended by IMA SDK documentation:
105
+ // https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/get-started
106
+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
94
107
  }
95
108
 
96
109
  // Cast dependencies
@@ -1,5 +1,7 @@
1
1
  package com.jwplayer.rnjwplayer;
2
2
 
3
+ import android.util.Log;
4
+
3
5
  import android.os.Handler;
4
6
  import android.os.Looper;
5
7
 
@@ -430,6 +432,31 @@ public class RNJWPlayerModule extends ReactContextBaseJavaModule {
430
432
  });
431
433
  }
432
434
 
435
+ @ReactMethod
436
+ /**
437
+ * Reconfigures or recreates the player with a new configuration.
438
+ *
439
+ * This method intelligently determines whether to:
440
+ * 1. Reconfigure the existing player (preferred, ~90% of cases)
441
+ * 2. Recreate the player (only when necessary, e.g., license changes)
442
+ *
443
+ * Note: Despite the name "recreate", this method usually does NOT recreate the player.
444
+ * It follows the JWPlayer SDK's design intent of reusing player instances via setup() calls.
445
+ *
446
+ * This provides API parity with iOS while being more efficient on Android.
447
+ */
448
+ public void recreatePlayerWithConfig(final int reactTag, final ReadableMap config) {
449
+ new Handler(Looper.getMainLooper()).post(() -> {
450
+ RNJWPlayerView playerView = getPlayerView(reactTag);
451
+ if (playerView != null) {
452
+ // Delegate to setConfig() which intelligently handles reconfiguration vs recreation
453
+ playerView.setConfig(config);
454
+ } else {
455
+ Log.e("RNJWPlayer", "recreatePlayerWithConfig: Player view not found for tag " + reactTag);
456
+ }
457
+ });
458
+ }
459
+
433
460
  private int stateToInt(PlayerState playerState) {
434
461
  switch (playerState) {
435
462
  case IDLE: