bitmovin-player-react-native 0.3.0 → 0.4.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 +238 -24
- package/RNBitmovinPlayer.podspec +3 -1
- package/android/build.gradle +7 -5
- 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 +273 -2
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +45 -5
- 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 +301 -7
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableArray.kt +35 -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/RNPictureInPictureHandler.kt +191 -0
- package/ios/AudioSessionModule.m +10 -0
- package/ios/AudioSessionModule.swift +65 -0
- package/ios/Event+JSON.swift +123 -0
- package/ios/PlayerModule.m +6 -0
- package/ios/PlayerModule.swift +44 -0
- package/ios/RCTConvert+BitmovinPlayer.swift +285 -15
- package/ios/RNPlayerView+PlayerListener.swift +52 -0
- package/ios/RNPlayerView+UserInterfaceListener.swift +19 -0
- package/ios/RNPlayerView.swift +17 -0
- package/ios/RNPlayerViewManager.m +18 -1
- package/ios/RNPlayerViewManager.swift +2 -1
- package/lib/index.d.ts +577 -3
- package/lib/index.js +92 -33
- package/lib/index.mjs +75 -19
- package/package.json +1 -1
- package/src/advertising.ts +155 -0
- package/src/audioSession.ts +47 -0
- package/src/components/PlayerView/events.ts +39 -3
- package/src/components/PlayerView/index.tsx +31 -11
- package/src/events.ts +212 -0
- package/src/index.ts +2 -0
- package/src/player.ts +41 -1
- package/src/tweaksConfig.ts +153 -0
package/lib/index.js
CHANGED
|
@@ -31,6 +31,9 @@ var __publicField = (obj, key, value) => {
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
AdQuartile: () => AdQuartile,
|
|
35
|
+
AdSourceType: () => AdSourceType,
|
|
36
|
+
AudioSession: () => AudioSession,
|
|
34
37
|
Drm: () => Drm,
|
|
35
38
|
LoadingState: () => LoadingState,
|
|
36
39
|
Player: () => Player,
|
|
@@ -42,18 +45,43 @@ __export(src_exports, {
|
|
|
42
45
|
});
|
|
43
46
|
module.exports = __toCommonJS(src_exports);
|
|
44
47
|
|
|
48
|
+
// src/advertising.ts
|
|
49
|
+
var AdQuartile = /* @__PURE__ */ ((AdQuartile2) => {
|
|
50
|
+
AdQuartile2["FIRST"] = "first";
|
|
51
|
+
AdQuartile2["MID_POINT"] = "mid_point";
|
|
52
|
+
AdQuartile2["THIRD"] = "third";
|
|
53
|
+
return AdQuartile2;
|
|
54
|
+
})(AdQuartile || {});
|
|
55
|
+
var AdSourceType = /* @__PURE__ */ ((AdSourceType2) => {
|
|
56
|
+
AdSourceType2["IMA"] = "ima";
|
|
57
|
+
AdSourceType2["UNKNOWN"] = "unknown";
|
|
58
|
+
AdSourceType2["PROGRESSIVE"] = "progressive";
|
|
59
|
+
return AdSourceType2;
|
|
60
|
+
})(AdSourceType || {});
|
|
61
|
+
|
|
62
|
+
// src/audioSession.ts
|
|
63
|
+
var import_react_native = require("react-native");
|
|
64
|
+
var AudioSessionModule = import_react_native.NativeModules.AudioSessionModule;
|
|
65
|
+
var AudioSession = {
|
|
66
|
+
setCategory: async (category) => {
|
|
67
|
+
if (AudioSessionModule) {
|
|
68
|
+
await AudioSessionModule.setCategory(category);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
45
73
|
// src/components/PlayerView/index.tsx
|
|
46
74
|
var import_react2 = __toESM(require("react"));
|
|
47
|
-
var
|
|
75
|
+
var import_react_native4 = require("react-native");
|
|
48
76
|
|
|
49
77
|
// src/components/PlayerView/native.ts
|
|
50
|
-
var
|
|
51
|
-
var NativePlayerView = (0,
|
|
78
|
+
var import_react_native2 = require("react-native");
|
|
79
|
+
var NativePlayerView = (0, import_react_native2.requireNativeComponent)("NativePlayerView");
|
|
52
80
|
|
|
53
81
|
// src/hooks/useProxy.ts
|
|
54
82
|
var import_lodash = __toESM(require("lodash.omit"));
|
|
55
83
|
var import_react = require("react");
|
|
56
|
-
var
|
|
84
|
+
var import_react_native3 = require("react-native");
|
|
57
85
|
function unwrapNativeEvent(event) {
|
|
58
86
|
return (0, import_lodash.default)(event.nativeEvent, ["target"]);
|
|
59
87
|
}
|
|
@@ -61,7 +89,7 @@ function useProxy(viewRef) {
|
|
|
61
89
|
return (0, import_react.useCallback)(
|
|
62
90
|
(callback) => (event) => {
|
|
63
91
|
const node = event.target._nativeTag;
|
|
64
|
-
if (node === (0,
|
|
92
|
+
if (node === (0, import_react_native3.findNodeHandle)(viewRef.current)) {
|
|
65
93
|
callback?.(unwrapNativeEvent(event));
|
|
66
94
|
}
|
|
67
95
|
},
|
|
@@ -70,38 +98,55 @@ function useProxy(viewRef) {
|
|
|
70
98
|
}
|
|
71
99
|
|
|
72
100
|
// src/components/PlayerView/index.tsx
|
|
73
|
-
var styles =
|
|
101
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
74
102
|
baseStyle: {
|
|
75
103
|
alignSelf: "stretch"
|
|
76
104
|
}
|
|
77
105
|
});
|
|
78
|
-
function dispatch(command, node,
|
|
79
|
-
const commandId =
|
|
80
|
-
|
|
106
|
+
function dispatch(command, node, ...args) {
|
|
107
|
+
const commandId = import_react_native4.Platform.OS === "android" ? import_react_native4.UIManager.NativePlayerView.Commands[command].toString() : import_react_native4.UIManager.getViewManagerConfig("NativePlayerView").Commands[command];
|
|
108
|
+
import_react_native4.UIManager.dispatchViewManagerCommand(
|
|
81
109
|
node,
|
|
82
110
|
commandId,
|
|
83
|
-
|
|
84
|
-
ios: [playerId],
|
|
85
|
-
android: [node, playerId]
|
|
86
|
-
})
|
|
111
|
+
import_react_native4.Platform.select({ ios: args, android: [node, ...args] })
|
|
87
112
|
);
|
|
88
113
|
}
|
|
89
|
-
function PlayerView(props) {
|
|
114
|
+
function PlayerView({ style, player, ...props }) {
|
|
90
115
|
const nativeView = (0, import_react2.useRef)(null);
|
|
91
116
|
const proxy = useProxy(nativeView);
|
|
92
|
-
const
|
|
117
|
+
const nativeViewStyle = import_react_native4.StyleSheet.flatten([styles.baseStyle, style]);
|
|
93
118
|
(0, import_react2.useEffect)(() => {
|
|
94
|
-
|
|
95
|
-
const node = (0,
|
|
96
|
-
|
|
97
|
-
|
|
119
|
+
player.initialize();
|
|
120
|
+
const node = (0, import_react_native4.findNodeHandle)(nativeView.current);
|
|
121
|
+
if (node) {
|
|
122
|
+
dispatch("attachPlayer", node, player.nativeId, player.config);
|
|
123
|
+
}
|
|
124
|
+
}, [player]);
|
|
98
125
|
return /* @__PURE__ */ import_react2.default.createElement(NativePlayerView, {
|
|
99
126
|
ref: nativeView,
|
|
100
|
-
style,
|
|
127
|
+
style: nativeViewStyle,
|
|
128
|
+
onAdBreakFinished: proxy(props.onAdBreakFinished),
|
|
129
|
+
onAdBreakStarted: proxy(props.onAdBreakStarted),
|
|
130
|
+
onAdClicked: proxy(props.onAdClicked),
|
|
131
|
+
onAdError: proxy(props.onAdError),
|
|
132
|
+
onAdFinished: proxy(props.onAdFinished),
|
|
133
|
+
onAdManifestLoad: proxy(props.onAdManifestLoad),
|
|
134
|
+
onAdManifestLoaded: proxy(props.onAdManifestLoaded),
|
|
135
|
+
onAdQuartile: proxy(props.onAdQuartile),
|
|
136
|
+
onAdScheduled: proxy(props.onAdScheduled),
|
|
137
|
+
onAdSkipped: proxy(props.onAdSkipped),
|
|
138
|
+
onAdStarted: proxy(props.onAdStarted),
|
|
101
139
|
onDestroy: proxy(props.onDestroy),
|
|
102
140
|
onEvent: proxy(props.onEvent),
|
|
103
141
|
onMuted: proxy(props.onMuted),
|
|
104
142
|
onPaused: proxy(props.onPaused),
|
|
143
|
+
onPictureInPictureAvailabilityChanged: proxy(
|
|
144
|
+
props.onPictureInPictureAvailabilityChanged
|
|
145
|
+
),
|
|
146
|
+
onPictureInPictureEnter: proxy(props.onPictureInPictureEnter),
|
|
147
|
+
onPictureInPictureEntered: proxy(props.onPictureInPictureEntered),
|
|
148
|
+
onPictureInPictureExit: proxy(props.onPictureInPictureExit),
|
|
149
|
+
onPictureInPictureExited: proxy(props.onPictureInPictureExited),
|
|
105
150
|
onPlay: proxy(props.onPlay),
|
|
106
151
|
onPlaybackFinished: proxy(props.onPlaybackFinished),
|
|
107
152
|
onPlayerActive: proxy(props.onPlayerActive),
|
|
@@ -111,6 +156,8 @@ function PlayerView(props) {
|
|
|
111
156
|
onReady: proxy(props.onReady),
|
|
112
157
|
onSeek: proxy(props.onSeek),
|
|
113
158
|
onSeeked: proxy(props.onSeeked),
|
|
159
|
+
onStallStarted: proxy(props.onStallStarted),
|
|
160
|
+
onStallEnded: proxy(props.onStallEnded),
|
|
114
161
|
onSourceError: proxy(props.onSourceError),
|
|
115
162
|
onSourceLoad: proxy(props.onSourceLoad),
|
|
116
163
|
onSourceLoaded: proxy(props.onSourceLoaded),
|
|
@@ -125,12 +172,12 @@ function PlayerView(props) {
|
|
|
125
172
|
}
|
|
126
173
|
|
|
127
174
|
// src/drm/index.ts
|
|
128
|
-
var
|
|
175
|
+
var import_react_native6 = require("react-native");
|
|
129
176
|
var import_BatchedBridge = __toESM(require("react-native/Libraries/BatchedBridge/BatchedBridge"));
|
|
130
177
|
|
|
131
178
|
// src/nativeInstance.ts
|
|
132
|
-
var
|
|
133
|
-
var Uuid =
|
|
179
|
+
var import_react_native5 = require("react-native");
|
|
180
|
+
var Uuid = import_react_native5.NativeModules.UuidModule;
|
|
134
181
|
var NativeInstance = class {
|
|
135
182
|
constructor(config) {
|
|
136
183
|
__publicField(this, "nativeId");
|
|
@@ -141,7 +188,7 @@ var NativeInstance = class {
|
|
|
141
188
|
};
|
|
142
189
|
|
|
143
190
|
// src/drm/index.ts
|
|
144
|
-
var DrmModule =
|
|
191
|
+
var DrmModule = import_react_native6.NativeModules.DrmModule;
|
|
145
192
|
var Drm = class extends NativeInstance {
|
|
146
193
|
constructor() {
|
|
147
194
|
super(...arguments);
|
|
@@ -169,11 +216,11 @@ var Drm = class extends NativeInstance {
|
|
|
169
216
|
}
|
|
170
217
|
});
|
|
171
218
|
__publicField(this, "onPrepareMessage", (message, assetId) => {
|
|
172
|
-
const config =
|
|
219
|
+
const config = import_react_native6.Platform.OS === "ios" ? this.config?.fairplay : this.config?.widevine;
|
|
173
220
|
if (config && config.prepareMessage) {
|
|
174
221
|
DrmModule.setPreparedMessage(
|
|
175
222
|
this.nativeId,
|
|
176
|
-
|
|
223
|
+
import_react_native6.Platform.OS === "ios" ? config.prepareMessage?.(message, assetId) : config.prepareMessage?.(message)
|
|
177
224
|
);
|
|
178
225
|
}
|
|
179
226
|
});
|
|
@@ -186,7 +233,7 @@ var Drm = class extends NativeInstance {
|
|
|
186
233
|
}
|
|
187
234
|
});
|
|
188
235
|
__publicField(this, "onPrepareLicense", (license) => {
|
|
189
|
-
const prepareLicense =
|
|
236
|
+
const prepareLicense = import_react_native6.Platform.OS === "ios" ? this.config?.fairplay?.prepareLicense : this.config?.widevine?.prepareLicense;
|
|
190
237
|
if (prepareLicense) {
|
|
191
238
|
DrmModule.setPreparedLicense(this.nativeId, prepareLicense(license));
|
|
192
239
|
}
|
|
@@ -214,11 +261,11 @@ var Drm = class extends NativeInstance {
|
|
|
214
261
|
var import_react3 = require("react");
|
|
215
262
|
|
|
216
263
|
// src/player.ts
|
|
217
|
-
var
|
|
264
|
+
var import_react_native8 = require("react-native");
|
|
218
265
|
|
|
219
266
|
// src/source.ts
|
|
220
|
-
var
|
|
221
|
-
var SourceModule =
|
|
267
|
+
var import_react_native7 = require("react-native");
|
|
268
|
+
var SourceModule = import_react_native7.NativeModules.SourceModule;
|
|
222
269
|
var SourceType = /* @__PURE__ */ ((SourceType2) => {
|
|
223
270
|
SourceType2["NONE"] = "none";
|
|
224
271
|
SourceType2["HLS"] = "hls";
|
|
@@ -283,7 +330,7 @@ var Source = class extends NativeInstance {
|
|
|
283
330
|
};
|
|
284
331
|
|
|
285
332
|
// src/player.ts
|
|
286
|
-
var PlayerModule =
|
|
333
|
+
var PlayerModule = import_react_native8.NativeModules.PlayerModule;
|
|
287
334
|
var Player = class extends NativeInstance {
|
|
288
335
|
constructor() {
|
|
289
336
|
super(...arguments);
|
|
@@ -354,7 +401,7 @@ var Player = class extends NativeInstance {
|
|
|
354
401
|
return PlayerModule.isLive(this.nativeId);
|
|
355
402
|
});
|
|
356
403
|
__publicField(this, "isAirPlayActive", async () => {
|
|
357
|
-
if (
|
|
404
|
+
if (import_react_native8.Platform.OS === "android") {
|
|
358
405
|
console.warn(
|
|
359
406
|
`[Player ${this.nativeId}] Method isAirPlayActive is not available for Android. Only iOS devices.`
|
|
360
407
|
);
|
|
@@ -363,7 +410,7 @@ var Player = class extends NativeInstance {
|
|
|
363
410
|
return PlayerModule.isAirPlayActive(this.nativeId);
|
|
364
411
|
});
|
|
365
412
|
__publicField(this, "isAirPlayAvailable", async () => {
|
|
366
|
-
if (
|
|
413
|
+
if (import_react_native8.Platform.OS === "android") {
|
|
367
414
|
console.warn(
|
|
368
415
|
`[Player ${this.nativeId}] Method isAirPlayAvailable is not available for Android. Only iOS devices.`
|
|
369
416
|
);
|
|
@@ -374,6 +421,15 @@ var Player = class extends NativeInstance {
|
|
|
374
421
|
__publicField(this, "getAvailableSubtitles", async () => {
|
|
375
422
|
return PlayerModule.getAvailableSubtitles(this.nativeId);
|
|
376
423
|
});
|
|
424
|
+
__publicField(this, "scheduleAd", (adItem) => {
|
|
425
|
+
PlayerModule.scheduleAd(this.nativeId, adItem);
|
|
426
|
+
});
|
|
427
|
+
__publicField(this, "skipAd", () => {
|
|
428
|
+
PlayerModule.skipAd(this.nativeId);
|
|
429
|
+
});
|
|
430
|
+
__publicField(this, "isAd", () => {
|
|
431
|
+
return PlayerModule.isAd(this.nativeId);
|
|
432
|
+
});
|
|
377
433
|
}
|
|
378
434
|
};
|
|
379
435
|
|
|
@@ -391,6 +447,9 @@ var SubtitleFormat = /* @__PURE__ */ ((SubtitleFormat2) => {
|
|
|
391
447
|
})(SubtitleFormat || {});
|
|
392
448
|
// Annotate the CommonJS export names for ESM import in node:
|
|
393
449
|
0 && (module.exports = {
|
|
450
|
+
AdQuartile,
|
|
451
|
+
AdSourceType,
|
|
452
|
+
AudioSession,
|
|
394
453
|
Drm,
|
|
395
454
|
LoadingState,
|
|
396
455
|
Player,
|
package/lib/index.mjs
CHANGED
|
@@ -5,6 +5,31 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// src/advertising.ts
|
|
9
|
+
var AdQuartile = /* @__PURE__ */ ((AdQuartile2) => {
|
|
10
|
+
AdQuartile2["FIRST"] = "first";
|
|
11
|
+
AdQuartile2["MID_POINT"] = "mid_point";
|
|
12
|
+
AdQuartile2["THIRD"] = "third";
|
|
13
|
+
return AdQuartile2;
|
|
14
|
+
})(AdQuartile || {});
|
|
15
|
+
var AdSourceType = /* @__PURE__ */ ((AdSourceType2) => {
|
|
16
|
+
AdSourceType2["IMA"] = "ima";
|
|
17
|
+
AdSourceType2["UNKNOWN"] = "unknown";
|
|
18
|
+
AdSourceType2["PROGRESSIVE"] = "progressive";
|
|
19
|
+
return AdSourceType2;
|
|
20
|
+
})(AdSourceType || {});
|
|
21
|
+
|
|
22
|
+
// src/audioSession.ts
|
|
23
|
+
import { NativeModules } from "react-native";
|
|
24
|
+
var AudioSessionModule = NativeModules.AudioSessionModule;
|
|
25
|
+
var AudioSession = {
|
|
26
|
+
setCategory: async (category) => {
|
|
27
|
+
if (AudioSessionModule) {
|
|
28
|
+
await AudioSessionModule.setCategory(category);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
8
33
|
// src/components/PlayerView/index.tsx
|
|
9
34
|
import React, { useRef, useEffect } from "react";
|
|
10
35
|
import {
|
|
@@ -43,33 +68,50 @@ var styles = StyleSheet.create({
|
|
|
43
68
|
alignSelf: "stretch"
|
|
44
69
|
}
|
|
45
70
|
});
|
|
46
|
-
function dispatch(command, node,
|
|
71
|
+
function dispatch(command, node, ...args) {
|
|
47
72
|
const commandId = Platform.OS === "android" ? UIManager.NativePlayerView.Commands[command].toString() : UIManager.getViewManagerConfig("NativePlayerView").Commands[command];
|
|
48
73
|
UIManager.dispatchViewManagerCommand(
|
|
49
74
|
node,
|
|
50
75
|
commandId,
|
|
51
|
-
Platform.select({
|
|
52
|
-
ios: [playerId],
|
|
53
|
-
android: [node, playerId]
|
|
54
|
-
})
|
|
76
|
+
Platform.select({ ios: args, android: [node, ...args] })
|
|
55
77
|
);
|
|
56
78
|
}
|
|
57
|
-
function PlayerView(props) {
|
|
79
|
+
function PlayerView({ style, player, ...props }) {
|
|
58
80
|
const nativeView = useRef(null);
|
|
59
81
|
const proxy = useProxy(nativeView);
|
|
60
|
-
const
|
|
82
|
+
const nativeViewStyle = StyleSheet.flatten([styles.baseStyle, style]);
|
|
61
83
|
useEffect(() => {
|
|
62
|
-
|
|
84
|
+
player.initialize();
|
|
63
85
|
const node = findNodeHandle2(nativeView.current);
|
|
64
|
-
|
|
65
|
-
|
|
86
|
+
if (node) {
|
|
87
|
+
dispatch("attachPlayer", node, player.nativeId, player.config);
|
|
88
|
+
}
|
|
89
|
+
}, [player]);
|
|
66
90
|
return /* @__PURE__ */ React.createElement(NativePlayerView, {
|
|
67
91
|
ref: nativeView,
|
|
68
|
-
style,
|
|
92
|
+
style: nativeViewStyle,
|
|
93
|
+
onAdBreakFinished: proxy(props.onAdBreakFinished),
|
|
94
|
+
onAdBreakStarted: proxy(props.onAdBreakStarted),
|
|
95
|
+
onAdClicked: proxy(props.onAdClicked),
|
|
96
|
+
onAdError: proxy(props.onAdError),
|
|
97
|
+
onAdFinished: proxy(props.onAdFinished),
|
|
98
|
+
onAdManifestLoad: proxy(props.onAdManifestLoad),
|
|
99
|
+
onAdManifestLoaded: proxy(props.onAdManifestLoaded),
|
|
100
|
+
onAdQuartile: proxy(props.onAdQuartile),
|
|
101
|
+
onAdScheduled: proxy(props.onAdScheduled),
|
|
102
|
+
onAdSkipped: proxy(props.onAdSkipped),
|
|
103
|
+
onAdStarted: proxy(props.onAdStarted),
|
|
69
104
|
onDestroy: proxy(props.onDestroy),
|
|
70
105
|
onEvent: proxy(props.onEvent),
|
|
71
106
|
onMuted: proxy(props.onMuted),
|
|
72
107
|
onPaused: proxy(props.onPaused),
|
|
108
|
+
onPictureInPictureAvailabilityChanged: proxy(
|
|
109
|
+
props.onPictureInPictureAvailabilityChanged
|
|
110
|
+
),
|
|
111
|
+
onPictureInPictureEnter: proxy(props.onPictureInPictureEnter),
|
|
112
|
+
onPictureInPictureEntered: proxy(props.onPictureInPictureEntered),
|
|
113
|
+
onPictureInPictureExit: proxy(props.onPictureInPictureExit),
|
|
114
|
+
onPictureInPictureExited: proxy(props.onPictureInPictureExited),
|
|
73
115
|
onPlay: proxy(props.onPlay),
|
|
74
116
|
onPlaybackFinished: proxy(props.onPlaybackFinished),
|
|
75
117
|
onPlayerActive: proxy(props.onPlayerActive),
|
|
@@ -79,6 +121,8 @@ function PlayerView(props) {
|
|
|
79
121
|
onReady: proxy(props.onReady),
|
|
80
122
|
onSeek: proxy(props.onSeek),
|
|
81
123
|
onSeeked: proxy(props.onSeeked),
|
|
124
|
+
onStallStarted: proxy(props.onStallStarted),
|
|
125
|
+
onStallEnded: proxy(props.onStallEnded),
|
|
82
126
|
onSourceError: proxy(props.onSourceError),
|
|
83
127
|
onSourceLoad: proxy(props.onSourceLoad),
|
|
84
128
|
onSourceLoaded: proxy(props.onSourceLoaded),
|
|
@@ -93,12 +137,12 @@ function PlayerView(props) {
|
|
|
93
137
|
}
|
|
94
138
|
|
|
95
139
|
// src/drm/index.ts
|
|
96
|
-
import { NativeModules as
|
|
140
|
+
import { NativeModules as NativeModules3, Platform as Platform2 } from "react-native";
|
|
97
141
|
import BatchedBridge from "react-native/Libraries/BatchedBridge/BatchedBridge";
|
|
98
142
|
|
|
99
143
|
// src/nativeInstance.ts
|
|
100
|
-
import { NativeModules } from "react-native";
|
|
101
|
-
var Uuid =
|
|
144
|
+
import { NativeModules as NativeModules2 } from "react-native";
|
|
145
|
+
var Uuid = NativeModules2.UuidModule;
|
|
102
146
|
var NativeInstance = class {
|
|
103
147
|
constructor(config) {
|
|
104
148
|
__publicField(this, "nativeId");
|
|
@@ -109,7 +153,7 @@ var NativeInstance = class {
|
|
|
109
153
|
};
|
|
110
154
|
|
|
111
155
|
// src/drm/index.ts
|
|
112
|
-
var DrmModule =
|
|
156
|
+
var DrmModule = NativeModules3.DrmModule;
|
|
113
157
|
var Drm = class extends NativeInstance {
|
|
114
158
|
constructor() {
|
|
115
159
|
super(...arguments);
|
|
@@ -182,11 +226,11 @@ var Drm = class extends NativeInstance {
|
|
|
182
226
|
import { useRef as useRef2 } from "react";
|
|
183
227
|
|
|
184
228
|
// src/player.ts
|
|
185
|
-
import { NativeModules as
|
|
229
|
+
import { NativeModules as NativeModules5, Platform as Platform3 } from "react-native";
|
|
186
230
|
|
|
187
231
|
// src/source.ts
|
|
188
|
-
import { NativeModules as
|
|
189
|
-
var SourceModule =
|
|
232
|
+
import { NativeModules as NativeModules4 } from "react-native";
|
|
233
|
+
var SourceModule = NativeModules4.SourceModule;
|
|
190
234
|
var SourceType = /* @__PURE__ */ ((SourceType2) => {
|
|
191
235
|
SourceType2["NONE"] = "none";
|
|
192
236
|
SourceType2["HLS"] = "hls";
|
|
@@ -251,7 +295,7 @@ var Source = class extends NativeInstance {
|
|
|
251
295
|
};
|
|
252
296
|
|
|
253
297
|
// src/player.ts
|
|
254
|
-
var PlayerModule =
|
|
298
|
+
var PlayerModule = NativeModules5.PlayerModule;
|
|
255
299
|
var Player = class extends NativeInstance {
|
|
256
300
|
constructor() {
|
|
257
301
|
super(...arguments);
|
|
@@ -342,6 +386,15 @@ var Player = class extends NativeInstance {
|
|
|
342
386
|
__publicField(this, "getAvailableSubtitles", async () => {
|
|
343
387
|
return PlayerModule.getAvailableSubtitles(this.nativeId);
|
|
344
388
|
});
|
|
389
|
+
__publicField(this, "scheduleAd", (adItem) => {
|
|
390
|
+
PlayerModule.scheduleAd(this.nativeId, adItem);
|
|
391
|
+
});
|
|
392
|
+
__publicField(this, "skipAd", () => {
|
|
393
|
+
PlayerModule.skipAd(this.nativeId);
|
|
394
|
+
});
|
|
395
|
+
__publicField(this, "isAd", () => {
|
|
396
|
+
return PlayerModule.isAd(this.nativeId);
|
|
397
|
+
});
|
|
345
398
|
}
|
|
346
399
|
};
|
|
347
400
|
|
|
@@ -358,6 +411,9 @@ var SubtitleFormat = /* @__PURE__ */ ((SubtitleFormat2) => {
|
|
|
358
411
|
return SubtitleFormat2;
|
|
359
412
|
})(SubtitleFormat || {});
|
|
360
413
|
export {
|
|
414
|
+
AdQuartile,
|
|
415
|
+
AdSourceType,
|
|
416
|
+
AudioSession,
|
|
361
417
|
Drm,
|
|
362
418
|
LoadingState,
|
|
363
419
|
Player,
|
package/package.json
CHANGED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quartiles that can be reached during an ad playback.
|
|
3
|
+
*/
|
|
4
|
+
export enum AdQuartile {
|
|
5
|
+
FIRST = 'first',
|
|
6
|
+
MID_POINT = 'mid_point',
|
|
7
|
+
THIRD = 'third',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The possible types an `AdSource` can be.
|
|
12
|
+
*/
|
|
13
|
+
export enum AdSourceType {
|
|
14
|
+
IMA = 'ima',
|
|
15
|
+
UNKNOWN = 'unknown',
|
|
16
|
+
PROGRESSIVE = 'progressive',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Represents an ad source which can be assigned to an `AdItem`. An `AdItem` can have multiple `AdSource`s
|
|
21
|
+
* as waterfalling option.
|
|
22
|
+
*/
|
|
23
|
+
export interface AdSource {
|
|
24
|
+
/**
|
|
25
|
+
* The ad tag / url to the ad manifest.
|
|
26
|
+
*/
|
|
27
|
+
tag: string;
|
|
28
|
+
/**
|
|
29
|
+
* The `AdSourceType` of this `AdSource`.
|
|
30
|
+
*/
|
|
31
|
+
type: AdSourceType;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents an ad break which can be scheduled for playback.
|
|
36
|
+
*
|
|
37
|
+
* One single `AdItem` can have multiple `AdSource`s where all but the first act as fallback ad sources
|
|
38
|
+
* if the first one fails to load. The start and end of an ad break are signaled via `AdBreakStartedEvent`
|
|
39
|
+
* and `AdBreakFinishedEvent`.
|
|
40
|
+
*/
|
|
41
|
+
export interface AdItem {
|
|
42
|
+
/**
|
|
43
|
+
* The playback position at which the ad break is scheduled to start. Default value is "pre".
|
|
44
|
+
*
|
|
45
|
+
* Possible values are:
|
|
46
|
+
* • "pre": pre-roll ad (for VoD and Live streaming)
|
|
47
|
+
* • "post": post-roll ad (for VoD streaming only)
|
|
48
|
+
* • fractional seconds: "10", "12.5" (mid-roll ad, for VoD and Live streaming)
|
|
49
|
+
* • percentage of the entire video duration: "25%", "50%" (mid-roll ad, for VoD streaming only)
|
|
50
|
+
* • timecode hh:mm:ss.mmm: "00:10:30.000", "01:00:00.000" (mid-roll ad, for VoD streaming only)
|
|
51
|
+
*/
|
|
52
|
+
position?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The `AdSource`s that make up this `AdItem`. The first ad source in this array is used as the main ad.
|
|
55
|
+
* Subsequent ad sources act as a fallback, meaning that if the main ad source does not provide a
|
|
56
|
+
* valid response, the subsequent ad sources will be utilized one after another.
|
|
57
|
+
*
|
|
58
|
+
* The fallback ad sources need to have the same `AdSourceType` as the main ad source.
|
|
59
|
+
*/
|
|
60
|
+
sources: AdSource[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Contains configuration values regarding the ads which should be played back by the player.
|
|
65
|
+
*/
|
|
66
|
+
export interface AdvertisingConfig {
|
|
67
|
+
/**
|
|
68
|
+
* The ad items that are scheduled when a new playback session is started via `Player.load()`.
|
|
69
|
+
*/
|
|
70
|
+
schedule: AdItem[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Contains the base configuration options for an ad.
|
|
75
|
+
*/
|
|
76
|
+
export interface AdConfig {
|
|
77
|
+
/**
|
|
78
|
+
* Specifies how many seconds of the main video content should be replaced by ad break(s).
|
|
79
|
+
*/
|
|
80
|
+
replaceContentDuration: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Holds various additional ad data.
|
|
85
|
+
*/
|
|
86
|
+
export interface AdData {
|
|
87
|
+
/**
|
|
88
|
+
* The average bitrate of the progressive media file as defined in the VAST response.
|
|
89
|
+
*/
|
|
90
|
+
bitrate?: number;
|
|
91
|
+
/**
|
|
92
|
+
* The maximum bitrate of the streaming media file as defined in the VAST response.
|
|
93
|
+
*/
|
|
94
|
+
maxBitrate?: number;
|
|
95
|
+
/**
|
|
96
|
+
* The MIME type of the media file or creative as defined in the VAST response.
|
|
97
|
+
*/
|
|
98
|
+
mimeType?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The minimum bitrate of the streaming media file as defined in the VAST response.
|
|
101
|
+
*/
|
|
102
|
+
minBitrate?: number;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Defines basic properties available for every ad type.
|
|
107
|
+
*/
|
|
108
|
+
export interface Ad {
|
|
109
|
+
/**
|
|
110
|
+
* The url the user should be redirected to when clicking the ad.
|
|
111
|
+
*/
|
|
112
|
+
clickThroughUrl?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Holds various additional `AdData`.
|
|
115
|
+
*/
|
|
116
|
+
data?: AdData;
|
|
117
|
+
/**
|
|
118
|
+
* The height of the ad.
|
|
119
|
+
*/
|
|
120
|
+
height: number;
|
|
121
|
+
/**
|
|
122
|
+
* Identifier for the ad. This might be autogenerated.
|
|
123
|
+
*/
|
|
124
|
+
id?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Determines whether an ad is linear, i.e. playback of main content needs to be paused for the ad.
|
|
127
|
+
*/
|
|
128
|
+
isLinear: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The corresponding media file url for the ad.
|
|
131
|
+
*/
|
|
132
|
+
mediaFileUrl?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The width of the ad.
|
|
135
|
+
*/
|
|
136
|
+
width: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Contains information about an ad break.
|
|
141
|
+
*/
|
|
142
|
+
export interface AdBreak {
|
|
143
|
+
/**
|
|
144
|
+
* The ads scheduled for this `AdBreak`.
|
|
145
|
+
*/
|
|
146
|
+
ads: Ad[];
|
|
147
|
+
/**
|
|
148
|
+
* The id of the corresponding `AdBreakConfig`. This will be auto-generated.
|
|
149
|
+
*/
|
|
150
|
+
id: string;
|
|
151
|
+
/**
|
|
152
|
+
* The time in seconds in the media timeline the `AdBreak` is scheduled for.
|
|
153
|
+
*/
|
|
154
|
+
scheduleTime: number;
|
|
155
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const AudioSessionModule = NativeModules.AudioSessionModule;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An audio session category defines a set of audio behaviors.
|
|
7
|
+
* Choose a category that most accurately describes the audio behavior you require.
|
|
8
|
+
*
|
|
9
|
+
* Note the `playback` category is required in order to properly enable picture in picture support.
|
|
10
|
+
*
|
|
11
|
+
* - `ambient`: The category for an app in which sound playback is nonprimary — that is, your app also works with the sound turned off.
|
|
12
|
+
* - `multiRoute`: The category for routing distinct streams of audio data to different output devices at the same time.
|
|
13
|
+
* - `playAndRecord`: The category for recording (input) and playback (output) of audio, such as for a Voice over Internet Protocol (VoIP) app.
|
|
14
|
+
* - `playback`: The category for playing recorded music or other sounds that are central to the successful use of your app.
|
|
15
|
+
* - `record`: The category for recording audio while also silencing playback audio.
|
|
16
|
+
* - `soloAmbient`: The default audio session category.
|
|
17
|
+
*
|
|
18
|
+
* @platform iOS
|
|
19
|
+
* @see https://developer.apple.com/documentation/avfaudio/avaudiosession/category
|
|
20
|
+
*/
|
|
21
|
+
export type AudioSessionCategory =
|
|
22
|
+
| 'ambient'
|
|
23
|
+
| 'multiRoute'
|
|
24
|
+
| 'playAndRecord'
|
|
25
|
+
| 'playback'
|
|
26
|
+
| 'record'
|
|
27
|
+
| 'soloAmbient';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An object that communicates to the system how you intend to use audio in your app.
|
|
31
|
+
*
|
|
32
|
+
* @platform iOS
|
|
33
|
+
* @see https://developer.apple.com/documentation/avfaudio/avaudiosession
|
|
34
|
+
*/
|
|
35
|
+
export const AudioSession = {
|
|
36
|
+
/**
|
|
37
|
+
* Sets the audio session's category.
|
|
38
|
+
*
|
|
39
|
+
* @platform iOS
|
|
40
|
+
* @see https://developer.apple.com/documentation/avfaudio/avaudiosession/1616583-setcategory
|
|
41
|
+
*/
|
|
42
|
+
setCategory: async (category: AudioSessionCategory): Promise<void> => {
|
|
43
|
+
if (AudioSessionModule) {
|
|
44
|
+
await AudioSessionModule.setCategory(category);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|