@npo/player 1.27.2 → 1.27.4

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 CHANGED
@@ -87,7 +87,7 @@ export default class NpoPlayer {
87
87
  return;
88
88
  }
89
89
  if (this.player.getVideoElement()?.src) {
90
- await this.player.unload();
90
+ await this.unload();
91
91
  }
92
92
  this.streamOptions = options;
93
93
  this.playerContext.player.removeClassFromNpoPlayerElement('npo-player-error');
@@ -327,7 +327,7 @@ export default class NpoPlayer {
327
327
  if (this.npoTag != undefined) {
328
328
  clearInterval(this.npoTag.heartbeatInterval);
329
329
  }
330
- this.player?.pause();
330
+ this.pause();
331
331
  if (this.playerContext) {
332
332
  this.npoPlayerServices.discardAdBreak(this.playerContext);
333
333
  }
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npo/player",
3
- "version": "1.27.2",
3
+ "version": "1.27.4",
4
4
  "description": "NPO Player",
5
5
  "author": "Publieke Omroep <player@npo.nl>",
6
6
  "contributors": [
@@ -1,13 +1,9 @@
1
1
  import { NpoPlayerUIVariants } from '../../types/interfaces';
2
2
  export function discardAdBreak(playerContext) {
3
3
  const { npoPlayer, player } = playerContext;
4
- const { adBreakActive } = npoPlayer;
5
- if (!player || adBreakActive === false)
4
+ const { adBreakActive, variant } = npoPlayer;
5
+ if (!player || (!adBreakActive && variant !== NpoPlayerUIVariants.AD))
6
6
  return;
7
7
  void playerContext.player.createUIManager(playerContext, NpoPlayerUIVariants.DEFAULT);
8
- const activeAdBreak = player.getActiveAdBreak();
9
- if (activeAdBreak?.id) {
10
- player.playerAPI.ads.discardAdBreak(activeAdBreak.id);
11
- }
12
- npoPlayer.adBreakActive = false;
8
+ playerContext.npoPlayer.adBreakActive = false;
13
9
  }
@@ -4,73 +4,36 @@ import { discardAdBreak } from './discardAdBreak';
4
4
  describe('discardAdBreak', () => {
5
5
  let mockNpoPlayerAPI;
6
6
  let npoPlayerMock;
7
- const activeAdBreakMock = { id: 'ad-break-id' };
8
7
  afterEach(() => {
9
8
  jest.resetAllMocks();
10
9
  });
11
10
  it('should not discard ad break if player is undefined', () => {
12
- npoPlayerMock = createMockNpoPlayer({
13
- adBreakActive: true
14
- });
15
- const playerContextMock = createPlayerContextMock({
16
- player: undefined,
17
- npoPlayer: npoPlayerMock
18
- });
11
+ npoPlayerMock = createMockNpoPlayer({ adBreakActive: true, variant: NpoPlayerUIVariants.AD });
12
+ const playerContextMock = createPlayerContextMock({ player: undefined, npoPlayer: npoPlayerMock });
19
13
  discardAdBreak(playerContextMock);
20
14
  expect(npoPlayerMock.adBreakActive).toBe(true);
21
15
  });
22
16
  it('should not discard ad break if adBreakActive is false', () => {
23
- mockNpoPlayerAPI = createMockNpoPlayerAPI({
24
- getActiveAdBreak: jest.fn().mockReturnValue(activeAdBreakMock),
25
- discardAdBreak: jest.fn()
26
- });
27
- npoPlayerMock = createMockNpoPlayer({
28
- adBreakActive: false
29
- });
30
- const playerContextMock = createPlayerContextMock({
31
- player: mockNpoPlayerAPI,
32
- npoPlayer: npoPlayerMock
33
- });
17
+ mockNpoPlayerAPI = createMockNpoPlayerAPI();
18
+ npoPlayerMock = createMockNpoPlayer({ adBreakActive: false });
19
+ const playerContextMock = createPlayerContextMock({ player: mockNpoPlayerAPI, npoPlayer: npoPlayerMock });
34
20
  discardAdBreak(playerContextMock);
35
- expect(mockNpoPlayerAPI.getActiveAdBreak).not.toHaveBeenCalled();
36
- expect(mockNpoPlayerAPI.playerAPI.ads.discardAdBreak).not.toHaveBeenCalled();
37
21
  expect(npoPlayerMock.adBreakActive).toBe(false);
38
22
  expect(playerContextMock.player.createUIManager).not.toHaveBeenCalled();
39
23
  });
40
- it('should discard active ad break if adBreakActive is true and ad break exists', () => {
41
- mockNpoPlayerAPI = createMockNpoPlayerAPI({
42
- getActiveAdBreak: jest.fn().mockReturnValue(activeAdBreakMock),
43
- discardAdBreak: jest.fn(),
44
- variant: NpoPlayerUIVariants.AD
45
- });
46
- npoPlayerMock = createMockNpoPlayer({
47
- adBreakActive: true
48
- });
49
- const playerContextMock = createPlayerContextMock({
50
- player: mockNpoPlayerAPI,
51
- npoPlayer: npoPlayerMock
52
- });
24
+ it('should discard ad break if adBreakActive is true', () => {
25
+ mockNpoPlayerAPI = createMockNpoPlayerAPI();
26
+ npoPlayerMock = createMockNpoPlayer({ adBreakActive: true, variant: NpoPlayerUIVariants.DEFAULT });
27
+ const playerContextMock = createPlayerContextMock({ player: mockNpoPlayerAPI, npoPlayer: npoPlayerMock });
53
28
  discardAdBreak(playerContextMock);
54
- expect(mockNpoPlayerAPI.getActiveAdBreak).toHaveBeenCalled();
55
- expect(mockNpoPlayerAPI.playerAPI.ads.discardAdBreak).toHaveBeenCalledWith(activeAdBreakMock.id);
56
29
  expect(npoPlayerMock.adBreakActive).toBe(false);
57
- expect(playerContextMock.player.createUIManager).toHaveBeenCalledWith(playerContextMock, NpoPlayerUIVariants.DEFAULT);
30
+ expect(playerContextMock.player.createUIManager).toHaveBeenCalled();
58
31
  });
59
- it('should not discard ad break if active ad break does not exist', () => {
60
- mockNpoPlayerAPI = createMockNpoPlayerAPI({
61
- getActiveAdBreak: jest.fn().mockReturnValue(undefined),
62
- discardAdBreak: jest.fn()
63
- });
64
- npoPlayerMock = createMockNpoPlayer({
65
- adBreakActive: true
66
- });
67
- const playerContextMock = createPlayerContextMock({
68
- player: mockNpoPlayerAPI,
69
- npoPlayer: npoPlayerMock
70
- });
32
+ it('should discard active ad break if conditions are met', () => {
33
+ mockNpoPlayerAPI = createMockNpoPlayerAPI();
34
+ npoPlayerMock = createMockNpoPlayer({ adBreakActive: true, variant: NpoPlayerUIVariants.AD });
35
+ const playerContextMock = createPlayerContextMock({ player: mockNpoPlayerAPI, npoPlayer: npoPlayerMock });
71
36
  discardAdBreak(playerContextMock);
72
- expect(mockNpoPlayerAPI.getActiveAdBreak).toHaveBeenCalled();
73
- expect(mockNpoPlayerAPI.playerAPI.ads.discardAdBreak).not.toHaveBeenCalled();
74
37
  expect(npoPlayerMock.adBreakActive).toBe(false);
75
38
  expect(playerContextMock.player.createUIManager).toHaveBeenCalledWith(playerContextMock, NpoPlayerUIVariants.DEFAULT);
76
39
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npo/player",
3
- "version": "1.27.2",
3
+ "version": "1.27.4",
4
4
  "description": "NPO Player",
5
5
  "author": "Publieke Omroep <player@npo.nl>",
6
6
  "contributors": [