bitmovin-player-react-native 0.3.1 → 0.5.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.
- package/README.md +486 -24
- package/RNBitmovinPlayer.podspec +5 -1
- package/android/build.gradle +8 -5
- package/android/src/main/java/com/bitmovin/player/reactnative/AnalyticsModule.kt +154 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/DrmModule.kt +4 -5
- package/android/src/main/java/com/bitmovin/player/reactnative/PlayerModule.kt +41 -5
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt +318 -2
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +70 -9
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewPackage.kt +3 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/SourceModule.kt +4 -5
- package/android/src/main/java/com/bitmovin/player/reactnative/UuidModule.kt +3 -1
- package/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +389 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/Any.kt +27 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReactContextExtension.kt +8 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableArray.kt +19 -2
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/String.kt +8 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/WritableMap.kt +19 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/ui/FullscreenHandlerBridge.kt +37 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/ui/FullscreenHandlerModule.kt +73 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/ui/RNPictureInPictureHandler.kt +191 -0
- package/ios/AnalyticsModule.m +14 -0
- package/ios/AnalyticsModule.swift +180 -0
- package/ios/AudioSessionModule.m +10 -0
- package/ios/AudioSessionModule.swift +65 -0
- package/ios/Event+JSON.swift +134 -0
- package/ios/FullscreenHandlerBridge.swift +33 -0
- package/ios/FullscreenHandlerModule.m +9 -0
- package/ios/FullscreenHandlerModule.swift +71 -0
- package/ios/PlayerModule.m +6 -0
- package/ios/PlayerModule.swift +44 -0
- package/ios/RCTConvert+BitmovinPlayer.swift +382 -0
- package/ios/RNPlayerView+PlayerListener.swift +56 -0
- package/ios/RNPlayerView+UserInterfaceListener.swift +35 -0
- package/ios/RNPlayerView.swift +22 -0
- package/ios/RNPlayerViewManager.m +24 -1
- package/ios/RNPlayerViewManager.swift +23 -1
- package/lib/index.d.ts +1013 -150
- package/lib/index.js +251 -48
- package/lib/index.mjs +231 -34
- package/package.json +1 -1
- package/src/advertising.ts +155 -0
- package/src/analytics/collector.ts +97 -0
- package/src/analytics/config.ts +218 -0
- package/src/analytics/index.ts +2 -0
- package/src/audioSession.ts +47 -0
- package/src/components/PlayerView/events.ts +49 -3
- package/src/components/PlayerView/index.tsx +68 -11
- package/src/components/PlayerView/native.ts +4 -1
- package/src/events.ts +255 -0
- package/src/index.ts +4 -0
- package/src/media.ts +33 -0
- package/src/player.ts +57 -1
- package/src/source.ts +4 -0
- package/src/styleConfig.ts +87 -0
- package/src/ui/fullscreenhandler.ts +19 -0
- package/src/ui/fullscreenhandlerbridge.ts +59 -0
package/README.md
CHANGED
|
@@ -7,25 +7,45 @@ Official React Native bindings for Bitmovin's mobile Player SDKs.
|
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
[](https://community.bitmovin.com/?utm_source=github&utm_medium=bitmovin-player-react-native&utm_campaign=dev-community)
|
|
9
9
|
|
|
10
|
-
>
|
|
10
|
+
> As the library is under active development, this means certain features from our native SDKs are not yet exposed through these React Native bindings.
|
|
11
|
+
> See [Feature Support](#feature-support) for an overview of the supported features.
|
|
12
|
+
>
|
|
13
|
+
> Not seeing the features you’re looking for?
|
|
14
|
+
> We are accepting community pull requests to this open-source project so please feel free to contribute.
|
|
15
|
+
> or let us know in [our community](https://community.bitmovin.com/c/requests/14) what features we should work on next.
|
|
11
16
|
|
|
12
17
|
- [Bitmovin Player React Native](#bitmovin-player-react-native)
|
|
13
18
|
- [Platform Support](#platform-support)
|
|
19
|
+
- [Feature Support](#feature-support)
|
|
14
20
|
- [Installation](#installation)
|
|
15
21
|
- [Add package dependency](#add-package-dependency)
|
|
16
22
|
- [Setup iOS Player SDK](#setup-ios-player-sdk)
|
|
17
23
|
- [Setup Android Player SDK](#setup-android-player-sdk)
|
|
18
24
|
- [Getting Started](#getting-started)
|
|
19
25
|
- [Setting up a license key](#setting-up-a-license-key)
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
- [
|
|
23
|
-
|
|
26
|
+
- [Through code](#through-code)
|
|
27
|
+
- [Through `Info.plist`](#through-infoplist)
|
|
28
|
+
- [Through `AndroidManifest.xml`](#through-androidmanifestxml)
|
|
29
|
+
- [Setting up the playback configuration](#setting-up-the-playback-configuration)
|
|
24
30
|
- [Accessing native `Player` instances](#accessing-native-player-instances)
|
|
25
31
|
- [Listening to events](#listening-to-events)
|
|
26
32
|
- [Enabling DRM protection](#enabling-drm-protection)
|
|
27
33
|
- [Prepare hooks](#prepare-hooks)
|
|
28
34
|
- [Adding external subtitle tracks](#adding-external-subtitle-tracks)
|
|
35
|
+
- [Adding external thumbnail track](#adding-external-thumbnail-track)
|
|
36
|
+
- [Enabling Picture in Picture mode](#enabling-picture-in-picture-mode)
|
|
37
|
+
- [Android](#android)
|
|
38
|
+
- [iOS](#ios)
|
|
39
|
+
- [Showing the Picture in Picture UI option](#showing-the-picture-in-picture-ui-option)
|
|
40
|
+
- [Supported Picture in Picture events](#supported-picture-in-picture-events)
|
|
41
|
+
- [Customize HTML UI](#customize-html-ui-android-and-ios-only)
|
|
42
|
+
- [Setting up fullscreen handling](#setting-up-fullscreen-handling)
|
|
43
|
+
- [Supported fullscreen related events](#supported-fullscreen-related-events)
|
|
44
|
+
- [Setting up ads](#setting-up-ads)
|
|
45
|
+
- [Static ads configuration](#static-ads-configuration)
|
|
46
|
+
- [Dynamic ads scheduling](#dynamic-ads-scheduling)
|
|
47
|
+
- [Supported ads events](#supported-ads-events)
|
|
48
|
+
- [Setting up analytics](#setting-up-analytics)
|
|
29
49
|
- [Contributing](#contributing)
|
|
30
50
|
|
|
31
51
|
## Platform Support
|
|
@@ -40,6 +60,19 @@ This library requires at least React Native 0.64+ and React 17+ to work properly
|
|
|
40
60
|
|
|
41
61
|
Please note that browsers and other browser-like environments such as webOS and Tizen are not supported.
|
|
42
62
|
|
|
63
|
+
## Feature Support
|
|
64
|
+
|
|
65
|
+
Features of the native mobile Player SDKs are progressively being implemented in this React Native library. The table below summarizes the current state of the main Player SDK features.
|
|
66
|
+
|
|
67
|
+
| Feature | State |
|
|
68
|
+
| -------------------------------- | ----------------------------------------- |
|
|
69
|
+
| Playback of DRM-protected assets | :white_check_mark: Available since v0.2.0 |
|
|
70
|
+
| Subtitles & Captions | :white_check_mark: Available since v0.2.0 |
|
|
71
|
+
| Advertising | :white_check_mark: Available since v0.4.0 |
|
|
72
|
+
| Playlist API | :x: Not available |
|
|
73
|
+
| Offline Playback | :x: Not available |
|
|
74
|
+
| Analytics | :x: Coming Q1 2023 |
|
|
75
|
+
|
|
43
76
|
## Installation
|
|
44
77
|
|
|
45
78
|
Since Bitmovin's native SDKs are distributed through custom [Cocoapods](https://github.com/bitmovin/cocoapod-specs) and [Maven](https://artifacts.bitmovin.com/ui/native/public-releases) repositories, the installation cannot be managed by React Native's Autolink and requires some extra steps. Please refer to the installation instructions for each platform below. For more information on integrating the native SDKs, refer to the [Getting Started guides](https://bitmovin.com/docs/getting-started).
|
|
@@ -200,7 +233,7 @@ First of all, create a license key on the [Dashboard](https://bitmovin.com/dashb
|
|
|
200
233
|
|
|
201
234
|
Then your license key can be either set from code or by configuring `Info.plist` and `AndroidManifest.xml`.
|
|
202
235
|
|
|
203
|
-
####
|
|
236
|
+
#### Through code
|
|
204
237
|
|
|
205
238
|
```typescript
|
|
206
239
|
// Simply pass the `licenseKey` property to `PlayerConfig` when instantiating a player.
|
|
@@ -219,7 +252,24 @@ const player = new Player({
|
|
|
219
252
|
});
|
|
220
253
|
```
|
|
221
254
|
|
|
222
|
-
|
|
255
|
+
#### Through `Info.plist`
|
|
256
|
+
|
|
257
|
+
Add the following lines to the `<dict>` section of your `ios/Info.plist`:
|
|
258
|
+
|
|
259
|
+
```xml
|
|
260
|
+
<key>BitmovinPlayerLicenseKey</key>
|
|
261
|
+
<string>ENTER-YOUR-LICENSE-KEY</string>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Through `AndroidManifest.xml`
|
|
265
|
+
|
|
266
|
+
Add the following line to the `<application>` section of your `android/app/src/main/AndroidManifest.xml`:
|
|
267
|
+
|
|
268
|
+
```xml
|
|
269
|
+
<meta-data android:name="BITMOVIN_PLAYER_LICENSE_KEY" android:value="ENTER-YOUR-LICENSE-KEY" />
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Setting up the playback configuration
|
|
223
273
|
|
|
224
274
|
If needed, the default player behavior can be configured through the `playbackConfig` key when initialized.
|
|
225
275
|
|
|
@@ -239,6 +289,14 @@ const player = usePlayer({
|
|
|
239
289
|
// Whether background playback is enabled or not. Default is false.
|
|
240
290
|
// Only available for iOS.
|
|
241
291
|
isBackgroundPlaybackEnabled: true,
|
|
292
|
+
// Enable the Picture in Picture mode option on the player controls.
|
|
293
|
+
//
|
|
294
|
+
// Note iOS requires the audio session category of your app to be set to `playback` otherwise
|
|
295
|
+
// PiP mode won't work.
|
|
296
|
+
//
|
|
297
|
+
// Check out `Enabling Picture in Picture mode` section of README for more information
|
|
298
|
+
// on how to properly configure your app to support PiP.
|
|
299
|
+
isPictureInPictureEnabled: true,
|
|
242
300
|
},
|
|
243
301
|
});
|
|
244
302
|
|
|
@@ -251,27 +309,11 @@ const player = new Player({
|
|
|
251
309
|
isMuted: true,
|
|
252
310
|
isTimeShiftEnabled: true,
|
|
253
311
|
isBackgroundPlaybackEnabled: true,
|
|
312
|
+
isPictureInPictureEnabled: true,
|
|
254
313
|
},
|
|
255
314
|
});
|
|
256
315
|
```
|
|
257
316
|
|
|
258
|
-
#### Configuring `Info.plist`
|
|
259
|
-
|
|
260
|
-
Add the following lines to the `<dict>` section of your `ios/Info.plist`:
|
|
261
|
-
|
|
262
|
-
```xml
|
|
263
|
-
<key>BitmovinPlayerLicenseKey</key>
|
|
264
|
-
<string>ENTER-YOUR-LICENSE-KEY</string>
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
#### Configuring `AndroidManifest.xml`
|
|
268
|
-
|
|
269
|
-
Add the following line to the `<application>` section of your `android/app/src/main/AndroidManifest.xml`:
|
|
270
|
-
|
|
271
|
-
```xml
|
|
272
|
-
<meta-data android:name="BITMOVIN_PLAYER_LICENSE_KEY" android:value="ENTER-YOUR-LICENSE-KEY" />
|
|
273
|
-
```
|
|
274
|
-
|
|
275
317
|
### Accessing native `Player` instances
|
|
276
318
|
|
|
277
319
|
When you instantiate a player with `usePlayer` or `new Player()` from javascript, you're actually either creating a new `Player` instance in the native side (see [SDKs docs](https://bitmovin.com/docs/player/sdks) for more info) or referencing an existing one.
|
|
@@ -486,6 +528,426 @@ The supported `PlayerView` events for subtitles are:
|
|
|
486
528
|
|
|
487
529
|
You might check out a complete subtitle example in the [`example/`](https://github.com/bitmovin/bitmovin-player-react-native/tree/development/example) app.
|
|
488
530
|
|
|
531
|
+
### Adding external thumbnail track
|
|
532
|
+
|
|
533
|
+
Thumbnail seeking is a must have for any video longer than a few minutes. It increases usability and the general QoE [(Quality of Experience)](https://bitmovin.com/ultra-high-definition-quality-experience-mpeg-dash-part-1/) dramatically.
|
|
534
|
+
|
|
535
|
+
Setting up is simple with the Bitmovin Player. Thumbnails are loaded into the timeline as a track. All you need to do is to tell the player the location of the thumbnail file:
|
|
536
|
+
|
|
537
|
+
```typescript
|
|
538
|
+
import { Platform } from 'react-native';
|
|
539
|
+
import {
|
|
540
|
+
SourceConfig,
|
|
541
|
+
SourceType,
|
|
542
|
+
SubtitleFormat,
|
|
543
|
+
} from 'bitmovin-player-react-native';
|
|
544
|
+
|
|
545
|
+
// Source config with an external subtitle track.
|
|
546
|
+
const config: SourceConfig = {
|
|
547
|
+
url:
|
|
548
|
+
Platform.OS === 'ios'
|
|
549
|
+
? 'https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8'
|
|
550
|
+
: 'https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd',
|
|
551
|
+
type: Platform.OS === 'ios' ? SourceType.HLS : SourceType.DASH,
|
|
552
|
+
poster: 'https://bitmovin-a.akamaihd.net/content/sintel/poster.png',
|
|
553
|
+
// External thumbnail track url to be added to this source.
|
|
554
|
+
thumbnailTrack:
|
|
555
|
+
'https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/thumbnails/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.vtt',
|
|
556
|
+
};
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
What’s required for a video player with thumbnails
|
|
560
|
+
|
|
561
|
+
Adaptive Streaming relies on encoding your video into several groups of files (streams) at various resolutions, while thumbnails also need to be generated in the encoding process. The encoder creates a set of thumbnail images and combines them into a single image file (“Sprite”). For more information on encoding your videos, have a look at our [Cloud Encoding Service](https://bitmovin.com/encoding/).
|
|
562
|
+
|
|
563
|
+
### Enabling Picture in Picture mode
|
|
564
|
+
|
|
565
|
+
In order to make use of the Picture in Picture functionalities provided by the player, it's first necessary to configure your native application to properly support PiP.
|
|
566
|
+
|
|
567
|
+
The steps required for each platform are described below:
|
|
568
|
+
|
|
569
|
+
#### Android
|
|
570
|
+
|
|
571
|
+
**Declare Picture in Picture support on AndroidManifest.xml**
|
|
572
|
+
|
|
573
|
+
Open `android/app/src/main/AndroidManifest.xml` and set `android:supportsPictureInPicture` to `true`
|
|
574
|
+
on your main activity's manifest. Also, specify that your activity handles layout configuration changes
|
|
575
|
+
so that your activity doesn't relaunch when layout changes occur during PiP mode transitions:
|
|
576
|
+
|
|
577
|
+
```xml
|
|
578
|
+
<activity android:name=".MainActivity"
|
|
579
|
+
android:supportsPictureInPicture="true"
|
|
580
|
+
android:configChanges=
|
|
581
|
+
"screenSize|smallestScreenSize|screenLayout|orientation"
|
|
582
|
+
...
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
#### iOS
|
|
586
|
+
|
|
587
|
+
**Set background modes capability**
|
|
588
|
+
|
|
589
|
+
Make sure to add the `UIBackgroundModes` key to the `dict` section of your `Info.plist`:
|
|
590
|
+
|
|
591
|
+
```xml
|
|
592
|
+
<key>UIBackgroundModes</key>
|
|
593
|
+
<array>
|
|
594
|
+
<string>audio</string>
|
|
595
|
+
</array>
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
This step can also be performed from [Xcode](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes).
|
|
599
|
+
|
|
600
|
+
**Configure audio session on app startup**
|
|
601
|
+
|
|
602
|
+
Configure your app's `AudioSession` category to `playback` during the main component's initialization:
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
import { AudioSession } from 'bitmovin-player-react-native';
|
|
606
|
+
|
|
607
|
+
// App's root component
|
|
608
|
+
const App = () => {
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
// Set your app's `AudioSession` category to `playback` on initialization.
|
|
611
|
+
// Please, note even though this step is required for iOS it won't take any effect on Android.
|
|
612
|
+
AudioSession.setCategory('playback').catch((error) => {
|
|
613
|
+
// Handle any native error that might occur during this process.
|
|
614
|
+
handleError(error);
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
// ...
|
|
618
|
+
return /* ... */;
|
|
619
|
+
};
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
This step is required in order to properly enable background playback on iOS. Without it, the Picture in Picture option appears on the player UI but has no effect when used.
|
|
623
|
+
|
|
624
|
+
You can read more about it on [Apple's docs](https://developer.apple.com/documentation/avfaudio/avaudiosession/category/1616509-playback).
|
|
625
|
+
|
|
626
|
+
#### Showing the Picture in Picture UI option
|
|
627
|
+
|
|
628
|
+
Now that your native application is properly configured to support PiP changes, the player instance
|
|
629
|
+
in your JS code can be configured to show the Picture in Picture option in the player UI.
|
|
630
|
+
|
|
631
|
+
Simply add `isPictureInPictureEnabled: true` on your player's `playbackConfig` option:
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
const player = usePlayer({
|
|
635
|
+
playbackConfig: {
|
|
636
|
+
isPictureInPictureEnabled: true,
|
|
637
|
+
},
|
|
638
|
+
});
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
#### Supported Picture in Picture events
|
|
642
|
+
|
|
643
|
+
The supported Picture in Picture events on `PlayerView` are:
|
|
644
|
+
|
|
645
|
+
- `onPictureInPictureEnter`
|
|
646
|
+
- `onPictureInPictureExit`
|
|
647
|
+
|
|
648
|
+
**iOS only**
|
|
649
|
+
|
|
650
|
+
- `onPictureInPictureEntered`
|
|
651
|
+
- `onPictureInPictureExited`
|
|
652
|
+
|
|
653
|
+
**Android only**
|
|
654
|
+
|
|
655
|
+
- `onPictureInPictureAvailabilityChanged`
|
|
656
|
+
|
|
657
|
+
Check [`events.ts`](https://github.com/bitmovin/bitmovin-player-react-native/blob/development/src/components/PlayerView/events.ts) for more information about them.
|
|
658
|
+
|
|
659
|
+
### Customize HTML UI (Android and iOS only)
|
|
660
|
+
|
|
661
|
+
The Bitmovin Player SDKs use the open source [Bitmovin Player Web UI](https://github.com/bitmovin/bitmovin-player-ui) on all platforms, except tvOS.
|
|
662
|
+
The UI is customizable in multiple ways.
|
|
663
|
+
|
|
664
|
+
#### Custom implementation
|
|
665
|
+
|
|
666
|
+
Since the Bitmovin Player Web UI is open source, it can be forked and modified to tailor to any application's needs.
|
|
667
|
+
See [Cusomizing the UI](https://github.com/bitmovin/bitmovin-player-ui#customizing-the-ui) section for details.
|
|
668
|
+
|
|
669
|
+
In case a custom implementation of the Player UI is desired, configure the hosted JS and CSS files via the `StyleConfig` as shown in the following example:
|
|
670
|
+
|
|
671
|
+
```ts
|
|
672
|
+
const player = usePlayer({
|
|
673
|
+
styleConfig: {
|
|
674
|
+
playerUiCss: 'CUSTOM_UI_CSS_URL',
|
|
675
|
+
playerUiJs: 'CUSTOM_UI_JS_URL',
|
|
676
|
+
},
|
|
677
|
+
});
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
#### Custom CSS
|
|
681
|
+
|
|
682
|
+
Customization of the default built-in Bitmovin Player UI is possible via providing custom styling CSS by only configuring `playerUiCss` as shown in the following example:
|
|
683
|
+
|
|
684
|
+
```ts
|
|
685
|
+
const player = usePlayer({
|
|
686
|
+
styleConfig: {
|
|
687
|
+
playerUiCss: 'CUSTOM_UI_CSS_URL',
|
|
688
|
+
},
|
|
689
|
+
});
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### Supplemental CSS
|
|
693
|
+
|
|
694
|
+
In case the usage of the default Bitmovin Player UI is sufficient with minor additional styling, it can be achieved via providing the URL to the additional CSS stylesheet via `supplementalPlayerUiCss`.
|
|
695
|
+
|
|
696
|
+
```ts
|
|
697
|
+
const player = usePlayer({
|
|
698
|
+
styleConfig: {
|
|
699
|
+
supplementalPlayerUiCss: 'SUPPLEMENTAL_UI_CSS_URL',
|
|
700
|
+
},
|
|
701
|
+
});
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
### Setting up fullscreen handling
|
|
705
|
+
|
|
706
|
+
In order to enable the player to support fullscreen and show the fullscreen button when using the Bitmovin Player Web UI, a `FullscreenHandler` needs to be implemented.
|
|
707
|
+
Its responsibility is to update the UI when transitioning between fullscreen and non-fullscreen states.
|
|
708
|
+
The player view itself does not update it's presentation as the meaning of fullscreen is determined by the application integrating our library.
|
|
709
|
+
|
|
710
|
+
Here are the basics of enabling fullscreen support:
|
|
711
|
+
|
|
712
|
+
```typescript
|
|
713
|
+
// Define a handler to take care of fullscreen transitions
|
|
714
|
+
class SampleFullscreenHandler implements FullscreenHandler {
|
|
715
|
+
isFullscreenActive: boolean = true;
|
|
716
|
+
onFullscreen: (fullscreenMode: boolean) => void;
|
|
717
|
+
|
|
718
|
+
constructor(
|
|
719
|
+
isFullscreenActive: boolean,
|
|
720
|
+
onFullscreen: (fullscreenMode: boolean) => void
|
|
721
|
+
) {
|
|
722
|
+
this.isFullscreenActive = isFullscreenActive;
|
|
723
|
+
this.onFullscreen = onFullscreen;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
enterFullscreen(): void {
|
|
727
|
+
// Update UI state for fullscreen mode
|
|
728
|
+
this.onFullscreen(true);
|
|
729
|
+
this.isFullscreenActive = true;
|
|
730
|
+
console.log('enter fullscreen');
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
exitFullscreen(): void {
|
|
734
|
+
// Update UI state for non-fullscreen mode
|
|
735
|
+
this.onFullscreen(false);
|
|
736
|
+
this.isFullscreenActive = false;
|
|
737
|
+
console.log('exit fullscreen');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
export default function BasicFullscreenHandling() {
|
|
742
|
+
// Set up player and other components
|
|
743
|
+
|
|
744
|
+
// Create SampleFullscreenHandler instance and enable it to update state
|
|
745
|
+
const [fullscreenMode, setFullscreenMode] = useState(false);
|
|
746
|
+
const fullscreenHandler = new SampleFullscreenHandler(
|
|
747
|
+
fullscreenMode,
|
|
748
|
+
setFullscreenMode
|
|
749
|
+
);
|
|
750
|
+
|
|
751
|
+
return (
|
|
752
|
+
<View>
|
|
753
|
+
<PlayerView
|
|
754
|
+
player={player}
|
|
755
|
+
style={fullscreenMode ? styles.playerFullscreen : styles.player}
|
|
756
|
+
fullscreenHandler={fullscreenHandler}
|
|
757
|
+
onFullscreenEnter={onFullscreenEnter}
|
|
758
|
+
onFullscreenExit={onFullscreenExit}
|
|
759
|
+
onFullscreenEnabled={onFullscreenEnabled}
|
|
760
|
+
onFullscreenDisabled={onFullscreenDisabled}
|
|
761
|
+
/>
|
|
762
|
+
</View>
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Define your styles
|
|
767
|
+
const styles = StyleSheet.create({
|
|
768
|
+
player: {
|
|
769
|
+
flex: 1,
|
|
770
|
+
backgroundColor: 'black',
|
|
771
|
+
},
|
|
772
|
+
playerFullscreen: {
|
|
773
|
+
position: 'absolute',
|
|
774
|
+
top: 0,
|
|
775
|
+
right: 0,
|
|
776
|
+
bottom: 0,
|
|
777
|
+
left: 0,
|
|
778
|
+
backgroundColor: 'black',
|
|
779
|
+
},
|
|
780
|
+
});
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
Check [`BasicFullscreenHandling.tsx`](https://github.com/bitmovin/bitmovin-player-react-native/blob/development/example/src/screens/BasicFullscreenHandling.tsx) for a full example implementation.
|
|
784
|
+
|
|
785
|
+
#### Supported fullscreen related events
|
|
786
|
+
|
|
787
|
+
The supported fullscreen events on `PlayerView` are:
|
|
788
|
+
|
|
789
|
+
- `onFullscreenEnter`
|
|
790
|
+
- `onFullscreenExit`
|
|
791
|
+
- `onFullscreenEnabled`
|
|
792
|
+
- `onFullscreenDisabled`
|
|
793
|
+
|
|
794
|
+
Check [`events.ts`](https://github.com/bitmovin/bitmovin-player-react-native/blob/development/src/components/PlayerView/events.ts) for more information about them.
|
|
795
|
+
|
|
796
|
+
### Setting up ads
|
|
797
|
+
|
|
798
|
+
The Bitmovin Player SDKs are capable of displaying Ads out of the box and there are two ways they can be
|
|
799
|
+
configured with the player. One option is to use static configuration in the player config object,
|
|
800
|
+
and the other is to schedule them dynamically using `Player.scheduleAd`.
|
|
801
|
+
|
|
802
|
+
#### Static ads configuration
|
|
803
|
+
|
|
804
|
+
The easiest way to configure Ads is by adding the `advertisingConfig` property to the player configuration object.
|
|
805
|
+
All that needs to be provided is a URL pointing to a target Ad tag along with the type of the tag.
|
|
806
|
+
|
|
807
|
+
```typescript
|
|
808
|
+
const player = usePlayer({
|
|
809
|
+
licenseKey: '<PLAYER_LICENSE_KEY>',
|
|
810
|
+
advertisingConfig: {
|
|
811
|
+
// Each object in `schedule` represents an `AdItem`.
|
|
812
|
+
schedule: [
|
|
813
|
+
// An `AdItem` represents a time slot within the streamed content dedicated to ads playback.
|
|
814
|
+
{
|
|
815
|
+
// Each item specifies a list of sources with a type and URL to the ad manifest in the ads
|
|
816
|
+
// server. All but the first source act as fallback if the first one fails to load.
|
|
817
|
+
// The start and end of an ad break are signaled via `AdBreakStartedEvent` and `AdBreakFinishedEvent`.
|
|
818
|
+
sources: [
|
|
819
|
+
{
|
|
820
|
+
type: AdSourceType.IMA,
|
|
821
|
+
tag: 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=',
|
|
822
|
+
},
|
|
823
|
+
// Fallback sources...
|
|
824
|
+
],
|
|
825
|
+
// Each item also specifies the position where it should appear during playback.
|
|
826
|
+
// The possible position values are documented below.
|
|
827
|
+
// The default value is `pre`.
|
|
828
|
+
position: '20%',
|
|
829
|
+
},
|
|
830
|
+
],
|
|
831
|
+
},
|
|
832
|
+
});
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
The possible `AdItem` position values are:
|
|
836
|
+
|
|
837
|
+
- `"pre"`: pre-roll ad (for VoD and Live streaming; appears before playback starts)
|
|
838
|
+
- `"post"`: post-roll ad (for VoD streaming only; appears after playback finishes)
|
|
839
|
+
- Fractional seconds: `"10"`, `"12.5"` (mid-roll ad, for VoD and Live streaming)
|
|
840
|
+
- Percentage of the entire video duration: `"25%"`, `"50%"` (mid-roll ad, for VoD streaming only)
|
|
841
|
+
- Timecode `hh:mm:ss.mmm`: `"00:10:30.000"`, `"01:00:00.000"` (mid-roll ad, for VoD streaming only)
|
|
842
|
+
|
|
843
|
+
#### Dynamic ads scheduling
|
|
844
|
+
|
|
845
|
+
To gain more flexibility, it is also possible to schedule an `AdItem` dynamically in code using the
|
|
846
|
+
`Player` instance. To do this, you need to call the `scheduleAd` method.
|
|
847
|
+
|
|
848
|
+
```typescript
|
|
849
|
+
// The object passed to `scheduleAd` must be an `AdItem`.
|
|
850
|
+
player.scheduleAd({
|
|
851
|
+
// Ad source with fallbacks.
|
|
852
|
+
sources: [
|
|
853
|
+
{
|
|
854
|
+
tag: '<AD-URL>',
|
|
855
|
+
type: AdSourceType.IMA,
|
|
856
|
+
},
|
|
857
|
+
],
|
|
858
|
+
});
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
An `AdScheduledEvent` event is dispatched when the ad is successfully scheduled via `scheduleAd`.
|
|
862
|
+
|
|
863
|
+
Also, during playback, it's also possible to check whether an ad is being played with `player.isAd()`
|
|
864
|
+
and skip the ad being currently played with `player.skipAd()` (see `AdSkippedEvent`).
|
|
865
|
+
|
|
866
|
+
#### Supported ads events
|
|
867
|
+
|
|
868
|
+
The supported `PlayerView` events for ads are:
|
|
869
|
+
|
|
870
|
+
- `onAdBreakFinished`
|
|
871
|
+
- `onAdBreakStarted`
|
|
872
|
+
- `onAdClicked`
|
|
873
|
+
- `onAdError`
|
|
874
|
+
- `onAdFinished`
|
|
875
|
+
- `onAdManifestLoad`
|
|
876
|
+
- `onAdManifestLoaded`
|
|
877
|
+
- `onAdQuartile`
|
|
878
|
+
- `onAdScheduled`
|
|
879
|
+
- `onAdSkipped`
|
|
880
|
+
- `onAdStarted`
|
|
881
|
+
|
|
882
|
+
You can check out a complete ads example in the [`example/`](https://github.com/bitmovin/bitmovin-player-react-native/tree/development/example) app.
|
|
883
|
+
|
|
884
|
+
### Setting up analytics
|
|
885
|
+
|
|
886
|
+
Each `Player` instance has an associated analytics collector that can be configured to send analytics information about it. By default,
|
|
887
|
+
the associated collector is disabled unless an `analyticsConfig` option is specified. So in order to get analytics up and running, add the following configuration options to your `PlayerConfig`:
|
|
888
|
+
|
|
889
|
+
```typescript
|
|
890
|
+
const player = usePlayer({
|
|
891
|
+
analyticsConfig: {
|
|
892
|
+
// Bitmovin analytics key from the Analytics Dashboard
|
|
893
|
+
key: '<ANALYTICS-KEY>', // `key` is the only required parameter.
|
|
894
|
+
// Bitmovin player license key
|
|
895
|
+
playerKey: '<BITMOVIN-PLAYER-KEY>',
|
|
896
|
+
// Asset CDN provider. Check out `CdnProvider` on `src/analytics/config.ts` for more options.
|
|
897
|
+
cdnProvider: CdnProvider.AKAMAI,
|
|
898
|
+
// User-defined user ID.
|
|
899
|
+
customUserId: 'Custom user ID',
|
|
900
|
+
// Whether the user ID should be randomly generated or not. Default value is false.
|
|
901
|
+
randomizeUserId: false,
|
|
902
|
+
// Experiment name that'll appear at the Analytics Dashboard.
|
|
903
|
+
experimentName: 'Experiment name',
|
|
904
|
+
// Video ID on your server
|
|
905
|
+
videoId: 'MyVideoId',
|
|
906
|
+
// Video title
|
|
907
|
+
title: 'Art of Motion',
|
|
908
|
+
// Whether this is a live stream video. Default is false.
|
|
909
|
+
isLive: false,
|
|
910
|
+
// Whether collector should also collect statistics about ads
|
|
911
|
+
// Can be changed to `true` in case `advertisingConfig` is also present.
|
|
912
|
+
// Default is false.
|
|
913
|
+
ads: false,
|
|
914
|
+
// Navigation breadcrumb.
|
|
915
|
+
// The path taken by the user inside your application.
|
|
916
|
+
path: '/examples/basic_analytics',
|
|
917
|
+
// List of custom data fields to be registered at the Analytics Dashboard.
|
|
918
|
+
// Useful to customize collection with your own data along with the SDK.
|
|
919
|
+
customData1: 'Custom data field 1',
|
|
920
|
+
customData2: 'Custom data field 2',
|
|
921
|
+
customData3: 'Custom data field 3',
|
|
922
|
+
customData4: 'Custom data field 4',
|
|
923
|
+
customData5: 'Custom data field 5',
|
|
924
|
+
// Usage of customData properties are supported up to 30 fields
|
|
925
|
+
customData30: 'Custom data field 30',
|
|
926
|
+
},
|
|
927
|
+
});
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
And that's it. Now you should start receiving analytics information about your `player` instance on the [Analytics Dashboard](https://bitmovin.com/dashboard/analytics).
|
|
931
|
+
|
|
932
|
+
Optionally, you can also access the configured `analyticsCollector` object in order to get some information (like `userId`) or
|
|
933
|
+
update your custom data during runtime:
|
|
934
|
+
|
|
935
|
+
```typescript
|
|
936
|
+
// Get the current user id.
|
|
937
|
+
const userId = await player.analyticsCollector?.getUserId();
|
|
938
|
+
|
|
939
|
+
// Get the current custom data config.
|
|
940
|
+
const customData = await player.analyticsCollector?.getCustomData();
|
|
941
|
+
|
|
942
|
+
// Update the current custom data config.
|
|
943
|
+
player.analyticsCollector?.setCustomDataOnce({
|
|
944
|
+
customData2: 'Updated custom data field 2',
|
|
945
|
+
customData4: 'Updated custom data field 4',
|
|
946
|
+
});
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
You can check out a complete analytics example in the [`example/`](https://github.com/bitmovin/bitmovin-player-react-native/tree/development/example) app.
|
|
950
|
+
|
|
489
951
|
## Contributing
|
|
490
952
|
|
|
491
953
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
package/RNBitmovinPlayer.podspec
CHANGED
|
@@ -19,5 +19,9 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
20
20
|
|
|
21
21
|
s.dependency "React-Core"
|
|
22
|
-
s.dependency "BitmovinPlayer", "3.
|
|
22
|
+
s.dependency "BitmovinPlayer", "3.32.0"
|
|
23
|
+
s.dependency "BitmovinAnalyticsCollector/Core", "2.9.4"
|
|
24
|
+
s.dependency "BitmovinAnalyticsCollector/BitmovinPlayer", "2.9.4"
|
|
25
|
+
s.ios.dependency "GoogleAds-IMA-iOS-SDK", "3.17.0"
|
|
26
|
+
s.tvos.dependency "GoogleAds-IMA-tvOS-SDK", "4.6.1"
|
|
23
27
|
end
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
ext {
|
|
3
|
-
kotlinVersion = '1.7.
|
|
3
|
+
kotlinVersion = '1.7.21'
|
|
4
4
|
androidToolsVersion = '7.0.4'
|
|
5
5
|
}
|
|
6
6
|
repositories {
|
|
@@ -27,10 +27,10 @@ repositories {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
android {
|
|
30
|
-
compileSdk
|
|
30
|
+
compileSdk 33
|
|
31
31
|
defaultConfig {
|
|
32
|
-
minSdkVersion
|
|
33
|
-
targetSdkVersion
|
|
32
|
+
minSdkVersion 16
|
|
33
|
+
targetSdkVersion 33
|
|
34
34
|
versionCode 1
|
|
35
35
|
versionName '1.0'
|
|
36
36
|
}
|
|
@@ -50,6 +50,9 @@ android {
|
|
|
50
50
|
|
|
51
51
|
dependencies {
|
|
52
52
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
|
|
53
|
-
implementation 'com.
|
|
53
|
+
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.26.0'
|
|
54
|
+
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
|
55
|
+
implementation 'com.bitmovin.analytics:collector-bitmovin-player:2.12.1'
|
|
56
|
+
implementation 'com.bitmovin.player:player:3.26.1'
|
|
54
57
|
implementation 'com.facebook.react:react-native:+'
|
|
55
58
|
}
|