bitmovin-player-react-native 0.4.0 → 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 +249 -1
- package/RNBitmovinPlayer.podspec +3 -1
- package/android/build.gradle +3 -2
- package/android/src/main/java/com/bitmovin/player/reactnative/AnalyticsModule.kt +154 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt +45 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +25 -4
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewPackage.kt +3 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +172 -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/String.kt +8 -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/ios/AnalyticsModule.m +14 -0
- package/ios/AnalyticsModule.swift +180 -0
- package/ios/Event+JSON.swift +11 -0
- package/ios/FullscreenHandlerBridge.swift +33 -0
- package/ios/FullscreenHandlerModule.m +9 -0
- package/ios/FullscreenHandlerModule.swift +71 -0
- package/ios/RCTConvert+BitmovinPlayer.swift +174 -0
- package/ios/RNPlayerView+PlayerListener.swift +5 -1
- package/ios/RNPlayerView+UserInterfaceListener.swift +16 -0
- package/ios/RNPlayerView.swift +5 -0
- package/ios/RNPlayerViewManager.m +6 -0
- package/ios/RNPlayerViewManager.swift +21 -0
- package/lib/index.d.ts +498 -51
- package/lib/index.js +186 -42
- package/lib/index.mjs +167 -26
- package/package.json +1 -1
- package/src/analytics/collector.ts +97 -0
- package/src/analytics/config.ts +218 -0
- package/src/analytics/index.ts +2 -0
- package/src/components/PlayerView/events.ts +10 -0
- package/src/components/PlayerView/index.tsx +38 -1
- package/src/components/PlayerView/native.ts +4 -1
- package/src/events.ts +43 -0
- package/src/index.ts +2 -0
- package/src/media.ts +33 -0
- package/src/player.ts +21 -0
- 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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains config values which can be used to alter the visual presentation and behaviour of the player UI.
|
|
3
|
+
*/
|
|
4
|
+
export interface StyleConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Sets if the UI should be enabled or not. Default value is true.
|
|
7
|
+
* @example
|
|
8
|
+
* ```
|
|
9
|
+
* const player = new Player({
|
|
10
|
+
* styleConfig: {
|
|
11
|
+
* isUiEnabled: false,
|
|
12
|
+
* },
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
isUiEnabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Set the CSS file that will be used for the UI. The default CSS file will be completely replaced by the CSS file set with this property.
|
|
19
|
+
* @example
|
|
20
|
+
* ```
|
|
21
|
+
* const player = new Player({
|
|
22
|
+
* styleConfig: {
|
|
23
|
+
* playerUiCss: 'https://domain.tld/path/to/bitmovinplayer-ui.css',
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
* @platform iOS, Android
|
|
28
|
+
*/
|
|
29
|
+
playerUiCss?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Set a CSS file which contains supplemental styles for the player UI. These styles will be added to the default CSS file or the CSS file set with StyleConfig#playerUiCss.
|
|
32
|
+
* @example
|
|
33
|
+
* ```
|
|
34
|
+
* const player = new Player({
|
|
35
|
+
* styleConfig: {
|
|
36
|
+
* supplementalPlayerUiCss: 'https://domain.tld/path/to/bitmovinplayer-supplemental-ui.css',
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
* @platform iOS, Android
|
|
41
|
+
*/
|
|
42
|
+
supplementalPlayerUiCss?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the JS file that will be used for the UI. The default JS file will be completely replaced by the JS file set with this property.
|
|
45
|
+
* @example
|
|
46
|
+
* ```
|
|
47
|
+
* const player = new Player({
|
|
48
|
+
* styleConfig: {
|
|
49
|
+
* playerUiJs: 'https://domain.tld/path/to/bitmovinplayer-ui.js',
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
* @platform iOS, Android
|
|
54
|
+
*/
|
|
55
|
+
playerUiJs?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Determines how the video content is scaled or stretched within the parent container’s bounds. Possible values are defined in ScalingMode.
|
|
58
|
+
* Default value is ScalingMode.fit.
|
|
59
|
+
* @example
|
|
60
|
+
* ```
|
|
61
|
+
* const player = new Player({
|
|
62
|
+
* styleConfig: {
|
|
63
|
+
* scalingMode: ScalingMode.Zoom,
|
|
64
|
+
* },
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
scalingMode?: ScalingMode;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Specifies how the video content is scaled or stretched.
|
|
73
|
+
*/
|
|
74
|
+
export enum ScalingMode {
|
|
75
|
+
/**
|
|
76
|
+
* Specifies that the player should preserve the video’s aspect ratio and fit the video within the container's bounds.
|
|
77
|
+
*/
|
|
78
|
+
Fit = 'Fit',
|
|
79
|
+
/**
|
|
80
|
+
* Specifies that the video should be stretched to fill the container’s bounds. The aspect ratio may not be preserved.
|
|
81
|
+
*/
|
|
82
|
+
Stretch = 'Stretch',
|
|
83
|
+
/**
|
|
84
|
+
* Specifies that the player should preserve the video’s aspect ratio and fill the container’s bounds.
|
|
85
|
+
*/
|
|
86
|
+
Zoom = 'Zoom',
|
|
87
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the UI state change when fullscreen should be entered or exited.
|
|
3
|
+
*/
|
|
4
|
+
export interface FullscreenHandler {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates if the UI is currently in fullscreen mode
|
|
7
|
+
*/
|
|
8
|
+
isFullscreenActive: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Is called by the `PlayerView` when the UI should enter fullscreen mode.
|
|
12
|
+
*/
|
|
13
|
+
enterFullscreen(): void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Is called by the `PlayerView` when the UI should exit fullscreen mode.
|
|
17
|
+
*/
|
|
18
|
+
exitFullscreen(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
import BatchedBridge from 'react-native/Libraries/BatchedBridge/BatchedBridge';
|
|
3
|
+
import { FullscreenHandler } from './fullscreenhandler';
|
|
4
|
+
|
|
5
|
+
const Uuid = NativeModules.UuidModule;
|
|
6
|
+
const FullscreenHandlerModule = NativeModules.FullscreenHandlerModule;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Takes care of JS/Native communication for a FullscreenHandler.
|
|
10
|
+
*/
|
|
11
|
+
export class FullscreenHandlerBridge {
|
|
12
|
+
readonly nativeId: string;
|
|
13
|
+
fullscreenHandler?: FullscreenHandler;
|
|
14
|
+
isDestroyed: boolean;
|
|
15
|
+
|
|
16
|
+
constructor(nativeId?: string) {
|
|
17
|
+
this.nativeId = nativeId ?? Uuid.generate();
|
|
18
|
+
this.isDestroyed = false;
|
|
19
|
+
BatchedBridge.registerCallableModule(
|
|
20
|
+
`FullscreenBridge-${this.nativeId}`,
|
|
21
|
+
this
|
|
22
|
+
);
|
|
23
|
+
FullscreenHandlerModule.registerHandler(this.nativeId);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Destroys the native FullscreenHandler
|
|
28
|
+
*/
|
|
29
|
+
destroy() {
|
|
30
|
+
if (!this.isDestroyed) {
|
|
31
|
+
FullscreenHandlerModule.destroy(this.nativeId);
|
|
32
|
+
this.isDestroyed = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// noinspection JSUnusedGlobalSymbols
|
|
37
|
+
/**
|
|
38
|
+
* Called by native code, when the UI should enter fullscreen.
|
|
39
|
+
*/
|
|
40
|
+
enterFullscreen(): void {
|
|
41
|
+
this.fullscreenHandler?.enterFullscreen();
|
|
42
|
+
FullscreenHandlerModule.onFullscreenChanged(
|
|
43
|
+
this.nativeId,
|
|
44
|
+
this.fullscreenHandler?.isFullscreenActive ?? false
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// noinspection JSUnusedGlobalSymbols
|
|
49
|
+
/**
|
|
50
|
+
* Called by native code, when the UI should exit fullscreen.
|
|
51
|
+
*/
|
|
52
|
+
exitFullscreen(): void {
|
|
53
|
+
this.fullscreenHandler?.exitFullscreen();
|
|
54
|
+
FullscreenHandlerModule.onFullscreenChanged(
|
|
55
|
+
this.nativeId,
|
|
56
|
+
this.fullscreenHandler?.isFullscreenActive ?? false
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|