@npo/player 1.27.6 → 1.27.7
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/lib/npoplayer.js +3 -3
- package/lib/package.json +1 -1
- package/lib/services/npoPlayerAPI/npoPlayerAPI.js +1 -0
- package/lib/services/streamoptionsHandlers/streamOptionsHandler.js +2 -1
- package/lib/services/streamoptionsHandlers/streamOptionsHandler.test.js +1 -1
- package/lib/services/trackingHandlers/playerTrackerStart.js +1 -1
- package/lib/services/trackingHandlers/playerTrackerStart.test.js +29 -12
- package/lib/src/types/interfaces.d.ts +2 -2
- package/lib/types/interfaces.d.ts +2 -2
- package/package.json +1 -1
package/lib/npoplayer.js
CHANGED
|
@@ -114,12 +114,12 @@ export default class NpoPlayer {
|
|
|
114
114
|
customData5: this.version
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
+
this.npoPlayerServices.handleStreamOptions(this.playerContext);
|
|
117
118
|
void this.playerContext.player.createUIManager(this.playerContext, this.variant);
|
|
118
119
|
await this.playerContext.player?.load(this.sourceConfig);
|
|
119
120
|
this.npoPlayerServices.startPlayerTracker({
|
|
120
121
|
playerContext: this.playerContext,
|
|
121
|
-
source: source
|
|
122
|
-
duration: undefined
|
|
122
|
+
source: source
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
else if (sourceIsJWTToken) {
|
|
@@ -158,6 +158,7 @@ export default class NpoPlayer {
|
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
this.sourceConfig = await playerAction.processSourceConfig(this.npoPlayerServices, source, options.sourceConfig ?? {}, this.streamObject, drmType && drmType.length > 0 ? profile.drm : undefined, this.streamOptions, this.version, this.npoTag?.npoTagInstance);
|
|
161
|
+
this.npoPlayerServices.handleStreamOptions(this.playerContext);
|
|
161
162
|
await this.npoPlayerServices.verifyDRM(this.playerContext, payload);
|
|
162
163
|
const streamDuration = _streamObject.metadata.duration;
|
|
163
164
|
this.npoPlayerServices.startPlayerTracker({
|
|
@@ -169,7 +170,6 @@ export default class NpoPlayer {
|
|
|
169
170
|
else {
|
|
170
171
|
await this.npoPlayerServices.handleError(this.playerContext, 500);
|
|
171
172
|
}
|
|
172
|
-
this.npoPlayerServices.handleStreamOptions(this.playerContext);
|
|
173
173
|
this.npoPlayerServices.setupNicamKijkwijzerIcons(this.playerContext);
|
|
174
174
|
setupMediaSessionActionHandlers(this.player, this.sourceConfig, this.streamObject);
|
|
175
175
|
this.hidePlayNextScreen();
|
package/lib/package.json
CHANGED
|
@@ -172,6 +172,7 @@ export class NpoPlayerAPI {
|
|
|
172
172
|
playerContext.npoPlayer.uiManager = uiManager;
|
|
173
173
|
playerContext.npoPlayer.variant = variant;
|
|
174
174
|
npoPlayerServices.addUivisiblityHandlers(playerContext);
|
|
175
|
+
npoPlayerServices.setupNicamKijkwijzerIcons(playerContext);
|
|
175
176
|
npoPlayerServices.showNicamAfterUiDelay(playerContext);
|
|
176
177
|
}
|
|
177
178
|
}
|
|
@@ -70,7 +70,8 @@ export function setupAutoplay(playerContext) {
|
|
|
70
70
|
};
|
|
71
71
|
const doAutoPlay = async () => {
|
|
72
72
|
player.off(NpoPlayerEvent.Ready, handleAutoPlay);
|
|
73
|
+
player.off(NpoPlayerEvent.SourceLoaded, handleAutoPlay);
|
|
73
74
|
await player.play();
|
|
74
75
|
};
|
|
75
|
-
player.on(NpoPlayerEvent.
|
|
76
|
+
player.on(NpoPlayerEvent.SourceLoaded, handleAutoPlay);
|
|
76
77
|
}
|
|
@@ -178,7 +178,7 @@ describe('handleStreamOptions', () => {
|
|
|
178
178
|
player: mockNpoPlayerAPI
|
|
179
179
|
});
|
|
180
180
|
setupAutoplay(playerContextMock);
|
|
181
|
-
expect(playerContextMock.player.on).toHaveBeenCalledWith(NpoPlayerEvent.
|
|
181
|
+
expect(playerContextMock.player.on).toHaveBeenCalledWith(NpoPlayerEvent.SourceLoaded, expect.any(Function));
|
|
182
182
|
const handleAutoPlay = playerContextMock.player.on.mock.calls[0][1];
|
|
183
183
|
await handleAutoPlay();
|
|
184
184
|
expect(playerContextMock.player.play).toHaveBeenCalled();
|
|
@@ -17,7 +17,7 @@ export const startPlayerTracker = function ({ playerContext, source, duration })
|
|
|
17
17
|
}) || 'unknown';
|
|
18
18
|
npoPlayer.streamTracker = initStreamTracker({
|
|
19
19
|
playerContext: playerContext,
|
|
20
|
-
duration: getStreamDurationInSeconds({ duration: playerDuration }),
|
|
20
|
+
duration: getStreamDurationInSeconds({ duration: playerDuration, durationIsInMs: !!duration }),
|
|
21
21
|
source: analyticsPrid
|
|
22
22
|
});
|
|
23
23
|
bindPlayerEvents(playerContext);
|
|
@@ -22,31 +22,32 @@ jest.mock('./eventLogging', () => ({
|
|
|
22
22
|
}));
|
|
23
23
|
describe('startPlayerTracker', () => {
|
|
24
24
|
let playerContextMock;
|
|
25
|
+
let playerMock;
|
|
25
26
|
beforeEach(() => {
|
|
27
|
+
playerMock = { getDuration: jest.fn().mockReturnValue(200) };
|
|
26
28
|
playerContextMock = createPlayerContextMock({
|
|
27
29
|
npoPlayer: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
npoTagPageTracker: undefined
|
|
30
|
+
player: playerMock,
|
|
31
|
+
sourceConfig: {},
|
|
32
|
+
streamObject: {}
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
jest.clearAllMocks();
|
|
35
36
|
});
|
|
36
|
-
it('should initialize the stream tracker with
|
|
37
|
+
it('should initialize the stream tracker with the provided duration', () => {
|
|
37
38
|
const source = 'some-source';
|
|
38
39
|
const duration = 150;
|
|
39
40
|
getAnalyticsPrid.mockReturnValue('some-prid');
|
|
40
41
|
getStreamDurationInSeconds.mockReturnValue(duration);
|
|
41
|
-
startPlayerTracker({
|
|
42
|
-
playerContext: playerContextMock,
|
|
43
|
-
source,
|
|
44
|
-
duration
|
|
45
|
-
});
|
|
42
|
+
startPlayerTracker({ playerContext: playerContextMock, source, duration });
|
|
46
43
|
expect(getAnalyticsPrid).toHaveBeenCalledWith({
|
|
47
44
|
source,
|
|
48
|
-
sourceConfig:
|
|
49
|
-
streamObject:
|
|
45
|
+
sourceConfig: {},
|
|
46
|
+
streamObject: {}
|
|
47
|
+
});
|
|
48
|
+
expect(getStreamDurationInSeconds).toHaveBeenCalledWith({
|
|
49
|
+
duration,
|
|
50
|
+
durationIsInMs: true
|
|
50
51
|
});
|
|
51
52
|
expect(initStreamTracker).toHaveBeenCalledWith({
|
|
52
53
|
playerContext: playerContextMock,
|
|
@@ -56,4 +57,20 @@ describe('startPlayerTracker', () => {
|
|
|
56
57
|
expect(bindPlayerEvents).toHaveBeenCalledWith(playerContextMock);
|
|
57
58
|
expect(logEvent).toHaveBeenCalledWith({ playerContext: playerContextMock, event: 'load' });
|
|
58
59
|
});
|
|
60
|
+
it('should fallback to player.getDuration() if duration is not provided', () => {
|
|
61
|
+
const source = 'some-source';
|
|
62
|
+
const fallbackDuration = 200;
|
|
63
|
+
getAnalyticsPrid.mockReturnValue('some-prid');
|
|
64
|
+
getStreamDurationInSeconds.mockReturnValue(fallbackDuration);
|
|
65
|
+
startPlayerTracker({ playerContext: playerContextMock, source });
|
|
66
|
+
expect(getStreamDurationInSeconds).toHaveBeenCalledWith({
|
|
67
|
+
duration: fallbackDuration,
|
|
68
|
+
durationIsInMs: false
|
|
69
|
+
});
|
|
70
|
+
expect(initStreamTracker).toHaveBeenCalledWith({
|
|
71
|
+
playerContext: playerContextMock,
|
|
72
|
+
duration: fallbackDuration,
|
|
73
|
+
source: 'some-prid'
|
|
74
|
+
});
|
|
75
|
+
});
|
|
59
76
|
});
|
|
@@ -234,8 +234,8 @@ export type LocalStorageData = Partial<Record<LocalStorageValues, string | numbe
|
|
|
234
234
|
export type NPOGoogleCastRemoteControlConfig = GoogleCastRemoteControlConfig;
|
|
235
235
|
export interface PlayerTrackerParams {
|
|
236
236
|
playerContext: PlayerContext;
|
|
237
|
-
duration
|
|
238
|
-
source
|
|
237
|
+
duration?: number;
|
|
238
|
+
source?: string;
|
|
239
239
|
}
|
|
240
240
|
export interface LogEventParams {
|
|
241
241
|
playerContext: PlayerContext;
|
|
@@ -234,8 +234,8 @@ export type LocalStorageData = Partial<Record<LocalStorageValues, string | numbe
|
|
|
234
234
|
export type NPOGoogleCastRemoteControlConfig = GoogleCastRemoteControlConfig;
|
|
235
235
|
export interface PlayerTrackerParams {
|
|
236
236
|
playerContext: PlayerContext;
|
|
237
|
-
duration
|
|
238
|
-
source
|
|
237
|
+
duration?: number;
|
|
238
|
+
source?: string;
|
|
239
239
|
}
|
|
240
240
|
export interface LogEventParams {
|
|
241
241
|
playerContext: PlayerContext;
|