@applicaster/quick-brick-player 12.0.0-rc.99 → 13.0.0-alpha.2330880002
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/package.json +6 -6
- package/src/CellPlayer/ContextProvider.tsx +3 -3
- package/src/Player/index.tsx +21 -102
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.2330880002",
|
|
4
4
|
"description": "Quick Brick Player",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@applicaster/quick-brick-mobile-transport-controls": "12.0.0-rc.
|
|
40
|
-
"@applicaster/quick-brick-tv-transport-controls": "12.0.0-rc.
|
|
41
|
-
"@applicaster/zapp-react-native-tvos-app": "
|
|
42
|
-
"@applicaster/zapp-react-native-ui-components": "
|
|
43
|
-
"@applicaster/zapp-react-native-utils": "
|
|
39
|
+
"@applicaster/quick-brick-mobile-transport-controls": "12.0.0-rc.118",
|
|
40
|
+
"@applicaster/quick-brick-tv-transport-controls": "12.0.0-rc.112",
|
|
41
|
+
"@applicaster/zapp-react-native-tvos-app": "13.0.0-alpha.2330880002",
|
|
42
|
+
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.2330880002",
|
|
43
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.2330880002",
|
|
44
44
|
"keymirror": "^0.1.1",
|
|
45
45
|
"query-string": "7.1.3",
|
|
46
46
|
"react-native-web-linear-gradient": "1.1.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { memo } from "react";
|
|
2
2
|
import { LiveImageManager } from "@applicaster/zapp-react-native-ui-components/Components/VideoLive/LiveImageManager";
|
|
3
3
|
|
|
4
4
|
import { Context } from "./Context";
|
|
@@ -86,7 +86,7 @@ const initialEntryState = () => ({
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
export function ContextProvider(Component: ReactComponent<any>) {
|
|
89
|
-
return function DefaultPlayerProvider({
|
|
89
|
+
return memo(function DefaultPlayerProvider({
|
|
90
90
|
children,
|
|
91
91
|
}: CellActionContextProviderProps) {
|
|
92
92
|
const contextValue = React.useMemo(
|
|
@@ -104,5 +104,5 @@ export function ContextProvider(Component: ReactComponent<any>) {
|
|
|
104
104
|
<Component>{children}</Component>
|
|
105
105
|
</Context.Provider>
|
|
106
106
|
);
|
|
107
|
-
};
|
|
107
|
+
});
|
|
108
108
|
}
|
package/src/Player/index.tsx
CHANGED
|
@@ -21,14 +21,8 @@ import { PlayerWrapper } from "@applicaster/zapp-react-native-ui-components/Comp
|
|
|
21
21
|
|
|
22
22
|
import { PlayNextOverlay } from "./PlayNextOverlay";
|
|
23
23
|
import { PlayerImageBackground } from "@applicaster/zapp-react-native-ui-components/Components/PlayerImageBackground";
|
|
24
|
-
import { AnalyticsTracker } from "@applicaster/zapp-react-native-utils/analyticsUtils/analyticsTracker";
|
|
25
24
|
|
|
26
|
-
import {
|
|
27
|
-
AD_EVENT,
|
|
28
|
-
GENERAL_EVENT,
|
|
29
|
-
PLAYBACK_EVENT,
|
|
30
|
-
QOS_EVENT,
|
|
31
|
-
} from "@applicaster/zapp-react-native-utils/analyticsUtils/events";
|
|
25
|
+
import { GENERAL_EVENT } from "@applicaster/zapp-react-native-utils/analyticsUtils/events";
|
|
32
26
|
import { Categories, createLogger, Subsystem } from "../logger";
|
|
33
27
|
import { parseLanguageTracks } from "@applicaster/zapp-react-native-utils/playerUtils/configurationUtils";
|
|
34
28
|
import { DEFAULT_COLORS, SEEK_TIME } from "../utils/const";
|
|
@@ -42,6 +36,9 @@ import {
|
|
|
42
36
|
AnimationComponent,
|
|
43
37
|
ComponentAnimationType,
|
|
44
38
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
39
|
+
import { PlayerAnalyticsManager } from "@applicaster/zapp-react-native-utils/analyticsUtils/PlayerAnalyticsManager";
|
|
40
|
+
import { PlayerAnalyticsTrackerI } from "@applicaster/zapp-react-native-utils/analyticsUtils/playerAnalyticsTracker";
|
|
41
|
+
|
|
45
42
|
import { RNPlayerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/nativePlayerManager";
|
|
46
43
|
|
|
47
44
|
const styles = StyleSheet.create({
|
|
@@ -67,7 +64,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
67
64
|
> {
|
|
68
65
|
public static propTypes = {};
|
|
69
66
|
_root: any;
|
|
70
|
-
analyticsTracker: AnalyticsTracker;
|
|
71
67
|
playerPluginId: string;
|
|
72
68
|
takeParentStyle: Record<any, any>;
|
|
73
69
|
playbackStarted = false;
|
|
@@ -98,6 +94,17 @@ export default class VideoPlayer extends React.Component<
|
|
|
98
94
|
duration: 0,
|
|
99
95
|
};
|
|
100
96
|
|
|
97
|
+
private _tracker: PlayerAnalyticsTrackerI;
|
|
98
|
+
get analyticsTracker() {
|
|
99
|
+
if (!this._tracker) {
|
|
100
|
+
this._tracker = PlayerAnalyticsManager.getInstance().getTracker(
|
|
101
|
+
this.props.playerId
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return this._tracker;
|
|
106
|
+
}
|
|
107
|
+
|
|
101
108
|
constructor(props) {
|
|
102
109
|
super(props);
|
|
103
110
|
this.onVideoLoadCalled = false; // android
|
|
@@ -106,14 +113,13 @@ export default class VideoPlayer extends React.Component<
|
|
|
106
113
|
? { width: "100%", flex: "1 1 auto", objectFit: "contain" }
|
|
107
114
|
: { flexBasis: "auto", flexGrow: 1, flexShrink: 1 };
|
|
108
115
|
|
|
109
|
-
const entry = this.props?.entry;
|
|
110
|
-
this.analyticsTracker = new AnalyticsTracker(entry);
|
|
111
116
|
this.playerPluginId = this.props?.playerPluginIdentifier;
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
componentWillUnmount() {
|
|
115
120
|
this.playbackStarted = false;
|
|
116
|
-
|
|
121
|
+
|
|
122
|
+
this.analyticsTracker.handleAnalyticEvent(GENERAL_EVENT.session_end);
|
|
117
123
|
this.onPlayerClosed();
|
|
118
124
|
|
|
119
125
|
if (isAndroidPlatform()) {
|
|
@@ -174,27 +180,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
174
180
|
return this.props.pluginConfiguration;
|
|
175
181
|
};
|
|
176
182
|
|
|
177
|
-
/**
|
|
178
|
-
* Handles analytic events, generates a new analytics tracker and transmits events
|
|
179
|
-
* Passes entry data, and playerState to the tracker for additional context
|
|
180
|
-
* The end result is an event formatted and passed to AnalyticsBridge.postEvent
|
|
181
|
-
* When we get the synthetic event we need to pull the data in the nativeEvent object
|
|
182
|
-
* nativeEvent contains the return value from native
|
|
183
|
-
*/
|
|
184
|
-
handleAnalyticEvent = (event, data = {}) => {
|
|
185
|
-
const entry = this.props?.entry;
|
|
186
|
-
const playerState = this.getState();
|
|
187
|
-
|
|
188
|
-
if (this.analyticsTracker?.handleAnalyticEvent) {
|
|
189
|
-
this.analyticsTracker?.handleAnalyticEvent?.(
|
|
190
|
-
event,
|
|
191
|
-
{ ...data, player_type: this.props.playerPluginIdentifier },
|
|
192
|
-
entry,
|
|
193
|
-
playerState
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
183
|
/**
|
|
199
184
|
* This method is for the events that have no implementation in react but are being invoked by native
|
|
200
185
|
* When we get the synthetic event we need to pull the data in the nativeEvent object
|
|
@@ -268,12 +253,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
268
253
|
};
|
|
269
254
|
|
|
270
255
|
stopBackgroundPlayback = () => {
|
|
271
|
-
|
|
272
|
-
this.isReactNativeMethodsSupported() &&
|
|
273
|
-
RNPlayerManager?.[this.playerPluginId]?.stopBackgroundPlayback
|
|
274
|
-
) {
|
|
275
|
-
RNPlayerManager?.[this.playerPluginId]?.stopBackgroundPlayback();
|
|
276
|
-
}
|
|
256
|
+
RNPlayerManager?.[this.playerPluginId]?.stopBackgroundPlayback?.();
|
|
277
257
|
};
|
|
278
258
|
|
|
279
259
|
forward = (seekTime = SEEK_TIME) => {
|
|
@@ -394,28 +374,16 @@ export default class VideoPlayer extends React.Component<
|
|
|
394
374
|
};
|
|
395
375
|
|
|
396
376
|
onPlayerPresented = () => {
|
|
397
|
-
this.handleAnalyticEvent(GENERAL_EVENT.player_presented);
|
|
377
|
+
this.analyticsTracker?.handleAnalyticEvent(GENERAL_EVENT.player_presented);
|
|
398
378
|
};
|
|
399
379
|
|
|
400
380
|
onPlayerClosed = () => {
|
|
401
|
-
this.handleAnalyticEvent(GENERAL_EVENT.player_closed);
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
onPlayerSessionEnd = () => {
|
|
405
|
-
// TODO: Implement method on native android, ios exists
|
|
406
|
-
this.handleAnalyticEvent(GENERAL_EVENT.session_end);
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
onPlayerSessionStart = () => {
|
|
410
|
-
// TODO: Implement method on native android, ios exists
|
|
411
|
-
|
|
412
|
-
this.handleAnalyticEvent(GENERAL_EVENT.session_start);
|
|
381
|
+
this.analyticsTracker?.handleAnalyticEvent(GENERAL_EVENT.player_closed);
|
|
413
382
|
};
|
|
414
383
|
|
|
415
384
|
onVideoEnd = () => {
|
|
416
385
|
this.setState({ displayOverlay: !this.state.displayOverlay }, () => {
|
|
417
386
|
if (this.state?.displayOverlay) {
|
|
418
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.complete);
|
|
419
387
|
this.props?.listener?.onVideoEnd({});
|
|
420
388
|
}
|
|
421
389
|
});
|
|
@@ -425,15 +393,12 @@ export default class VideoPlayer extends React.Component<
|
|
|
425
393
|
onVideoError = ({ nativeEvent }) => {
|
|
426
394
|
const { message } = nativeEvent;
|
|
427
395
|
|
|
428
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.error, nativeEvent);
|
|
429
|
-
|
|
430
396
|
return this.props?.listener?.onError(new Error(message));
|
|
431
397
|
};
|
|
432
398
|
|
|
433
399
|
onPlayerPause = ({ nativeEvent = null }) => {
|
|
434
400
|
this.setState({ paused: true });
|
|
435
401
|
this.props?.listener?.onPlayerPause(nativeEvent);
|
|
436
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.pause, nativeEvent);
|
|
437
402
|
};
|
|
438
403
|
|
|
439
404
|
onPlayerResume = ({ nativeEvent = null }) => {
|
|
@@ -444,98 +409,61 @@ export default class VideoPlayer extends React.Component<
|
|
|
444
409
|
|
|
445
410
|
if (isNotAnAd && !resume) {
|
|
446
411
|
this.setState({ resume: true });
|
|
447
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.play, nativeEvent);
|
|
448
412
|
}
|
|
449
413
|
};
|
|
450
414
|
|
|
451
415
|
onPlayerSeekComplete = ({ nativeEvent }) => {
|
|
452
416
|
this.props?.listener?.onPlayerSeekComplete(nativeEvent);
|
|
453
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.seek_complete, nativeEvent);
|
|
454
417
|
};
|
|
455
418
|
|
|
456
419
|
onPlayerSeekStart = ({ nativeEvent }) => {
|
|
457
420
|
this.props?.listener?.onPlayerSeekStart(nativeEvent);
|
|
458
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.seek_start, nativeEvent);
|
|
459
421
|
};
|
|
460
422
|
|
|
461
423
|
onBufferStart = ({ nativeEvent }) => {
|
|
462
424
|
this.props?.listener?.onBufferStart(nativeEvent);
|
|
463
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.buffer_start, nativeEvent);
|
|
464
425
|
};
|
|
465
426
|
|
|
466
427
|
onBufferComplete = ({ nativeEvent }) => {
|
|
467
428
|
this.props?.listener?.onBufferComplete(nativeEvent);
|
|
468
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.buffer_complete, nativeEvent);
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
onPlayerNext = ({ nativeEvent }) => {
|
|
472
|
-
// TODO: Implement method on native
|
|
473
|
-
|
|
474
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.next, nativeEvent);
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
onPlayerPrevious = ({ nativeEvent }) => {
|
|
478
|
-
// TODO: Implement method on native
|
|
479
|
-
|
|
480
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.previous, nativeEvent);
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
onPlayerStop = ({ nativeEvent }) => {
|
|
484
|
-
// TODO: Implement method on native
|
|
485
|
-
|
|
486
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.stop, nativeEvent);
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
onVideoBandwidthUpdate = ({ nativeEvent }) => {
|
|
490
|
-
// TODO: Implement method on native
|
|
491
|
-
|
|
492
|
-
this.handleAnalyticEvent(QOS_EVENT.bitrate_changed, nativeEvent);
|
|
493
429
|
};
|
|
494
430
|
|
|
495
431
|
onAdBegin = ({ nativeEvent }) => {
|
|
496
432
|
this.setState({ isAd: true });
|
|
497
|
-
this.handleAnalyticEvent(AD_EVENT.ad_start, nativeEvent);
|
|
498
433
|
this.props.listener?.onAdBegin?.(nativeEvent);
|
|
499
434
|
};
|
|
500
435
|
|
|
501
436
|
onAdBreakBegin = ({ nativeEvent }) => {
|
|
502
437
|
this.setState({ isAd: true });
|
|
503
|
-
this.handleAnalyticEvent(AD_EVENT.ad_break_start, nativeEvent);
|
|
504
438
|
this.props.listener?.onAdBreakBegin?.(nativeEvent);
|
|
505
439
|
};
|
|
506
440
|
|
|
507
441
|
onAdBreakEnd = ({ nativeEvent }) => {
|
|
508
442
|
this.setState({ isAd: false });
|
|
509
|
-
this.handleAnalyticEvent(AD_EVENT.ad_break_completed, nativeEvent);
|
|
510
443
|
this.props.listener?.onAdBreakEnd?.(nativeEvent);
|
|
511
444
|
};
|
|
512
445
|
|
|
513
446
|
onAdEnd = ({ nativeEvent }) => {
|
|
514
447
|
this.setState({ isAd: false });
|
|
515
|
-
this.handleAnalyticEvent(AD_EVENT.ad_complete, nativeEvent);
|
|
516
448
|
this.props.listener?.onAdEnd?.(nativeEvent);
|
|
517
449
|
};
|
|
518
450
|
|
|
519
451
|
onAdError = ({ nativeEvent }) => {
|
|
520
452
|
this.setState({ isAd: false });
|
|
521
|
-
this.handleAnalyticEvent(AD_EVENT.ad_error, nativeEvent);
|
|
522
453
|
this.props.listener?.onAdError?.(nativeEvent);
|
|
523
454
|
};
|
|
524
455
|
|
|
525
456
|
onAdRequest = ({ nativeEvent }) => {
|
|
526
|
-
this.handleAnalyticEvent(AD_EVENT.ad_request, nativeEvent);
|
|
527
457
|
this.props.listener?.onAdRequest?.(nativeEvent);
|
|
528
458
|
};
|
|
529
459
|
|
|
530
460
|
onAdClicked = ({ nativeEvent }) => {
|
|
531
|
-
this.handleAnalyticEvent(AD_EVENT.ad_clicked, nativeEvent);
|
|
532
461
|
// Broadcast click event
|
|
533
462
|
this.props.playerEvent("ad-clicked", nativeEvent);
|
|
534
463
|
this.props.listener?.onAdClicked?.(nativeEvent);
|
|
535
464
|
};
|
|
536
465
|
|
|
537
466
|
onAdTapped = ({ nativeEvent }) => {
|
|
538
|
-
this.handleAnalyticEvent(AD_EVENT.ad_tapped, nativeEvent);
|
|
539
467
|
// Broadcast click event
|
|
540
468
|
this.props.playerEvent("ad-tapped", nativeEvent);
|
|
541
469
|
this.props.listener?.onAdTapped?.(nativeEvent);
|
|
@@ -648,10 +576,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
648
576
|
}
|
|
649
577
|
|
|
650
578
|
if (!this.state.isAd && !this.onVideoLoadCalled) {
|
|
651
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.load_video, {
|
|
652
|
-
player_type: this.props.playerPluginIdentifier,
|
|
653
|
-
});
|
|
654
|
-
|
|
655
579
|
// TODO: Hack, needs to remove
|
|
656
580
|
this.onVideoLoadCalled = true;
|
|
657
581
|
}
|
|
@@ -919,8 +843,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
919
843
|
onPlayerResume: this.onPlayerResume, // play
|
|
920
844
|
onPlayerSeekComplete: this.onPlayerSeekComplete, // seek_complete
|
|
921
845
|
onPlayerSeekStart: this.onPlayerSeekStart, // seek_start
|
|
922
|
-
onPlayerSessionEnd: this.onPlayerSessionEnd, // session_end
|
|
923
|
-
onPlayerSessionStart: this.onPlayerSessionStart, // session_start
|
|
924
846
|
};
|
|
925
847
|
|
|
926
848
|
const lifecycleEvents = {
|
|
@@ -953,7 +875,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
953
875
|
onTimedMetadata: this.unHandledEvent("onTimedMetadata"),
|
|
954
876
|
onTracksChanged: this.onTracksChanged,
|
|
955
877
|
eventSubtitlesChange: this.unHandledEvent("eventSubtitlesChange"),
|
|
956
|
-
onVideoBandwidthUpdate: this.onVideoBandwidthUpdate,
|
|
957
878
|
};
|
|
958
879
|
|
|
959
880
|
const playerSystemEvents = {
|
|
@@ -973,9 +894,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
973
894
|
const unsupportedEvents = {
|
|
974
895
|
onBufferComplete: this.onBufferComplete, // buffer_complete
|
|
975
896
|
onBufferStart: this.onBufferStart, // buffer_start
|
|
976
|
-
onPlayerNext: this.onPlayerNext, // next
|
|
977
|
-
onPlayerPrevious: this.onPlayerPrevious, // previous
|
|
978
|
-
onPlayerStop: this.onPlayerStop, // stop
|
|
979
897
|
};
|
|
980
898
|
|
|
981
899
|
const nativeEvents = {
|
|
@@ -1077,6 +995,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
1077
995
|
ref={this._assignRoot}
|
|
1078
996
|
{...nativeEvents}
|
|
1079
997
|
{...nativeProps}
|
|
998
|
+
listener={this.props.listener}
|
|
1080
999
|
/>
|
|
1081
1000
|
)}
|
|
1082
1001
|
<AudioPlayerWrapper {...sharedWrapperViewProps} />
|