@gcorevideo/player 2.24.3 → 2.24.6

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.
Files changed (33) hide show
  1. package/dist/core.js +2 -2
  2. package/dist/index.css +1424 -1424
  3. package/dist/index.embed.js +50978 -0
  4. package/dist/index.js +27 -15
  5. package/lib/Player.js +1 -1
  6. package/lib/index.embed.d.ts +34 -0
  7. package/lib/index.embed.d.ts.map +1 -0
  8. package/lib/index.embed.js +58 -0
  9. package/lib/plugins/big-mute-button/BigMuteButton.d.ts +3 -0
  10. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  11. package/lib/plugins/big-mute-button/BigMuteButton.js +19 -10
  12. package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
  13. package/lib/plugins/media-control/MediaControl.js +1 -1
  14. package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -1
  15. package/lib/plugins/seek-time/SeekTime.js +1 -0
  16. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  17. package/lib/plugins/source-controller/SourceController.js +3 -1
  18. package/lib/testUtils.d.ts.map +1 -1
  19. package/package.json +1 -2
  20. package/rollup.config.js +29 -0
  21. package/src/Player.ts +1 -1
  22. package/src/index.embed.ts +75 -0
  23. package/src/plugins/big-mute-button/BigMuteButton.ts +30 -19
  24. package/src/plugins/big-mute-button/__tests__/BigMuteButton.test.ts +60 -12
  25. package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
  26. package/src/plugins/media-control/MediaControl.ts +1 -1
  27. package/src/plugins/seek-time/SeekTime.ts +1 -0
  28. package/src/plugins/source-controller/SourceController.ts +4 -2
  29. package/src/testUtils.ts +4 -1
  30. package/tsconfig.tsbuildinfo +1 -1
  31. package/dist/player.d.ts +0 -3267
  32. package/dist/plugins/index.css +0 -2047
  33. package/dist/plugins/index.js +0 -18918
@@ -4,16 +4,19 @@ import { Events } from '@clappr/core'
4
4
  import { BigMuteButton } from '../BigMuteButton.js'
5
5
  import { createMockCore } from '../../../testUtils.js'
6
6
 
7
+ // import { Logger, LogTracer, setTracer } from '@gcorevideo/utils'
8
+
9
+ // setTracer(new LogTracer('BigMuteButton.test'))
10
+ // Logger.enable('*')
11
+
7
12
  describe('BigMuteButton', () => {
8
13
  let core: any
9
14
  let bmb: BigMuteButton
15
+ beforeEach(() => {
16
+ core = createMockCore({})
17
+ bmb = new BigMuteButton(core)
18
+ })
10
19
  describe('basically', () => {
11
- beforeEach(() => {
12
- core = createMockCore({})
13
- bmb = new BigMuteButton(core)
14
- // core.emit('core:ready')
15
- // core.emit('core:active:container:changed')
16
- })
17
20
  it('should render', () => {
18
21
  expect(bmb.$el.html()).toMatchSnapshot()
19
22
  })
@@ -22,17 +25,62 @@ describe('BigMuteButton', () => {
22
25
  describe.each([
23
26
  ['muted autoplay', 0, { autoPlay: true }, true],
24
27
  ['audible autoplay', 50, { autoPlay: true }, false],
25
- ['muted not autoplay', 0, { }, false],
26
- ['audible not autoplay', 1, {}, false],
27
- ])("%s", (_, volume, playMetadata, shouldMount) => {
28
+ ['muted not autoplay', 0, {}, false],
29
+ ['audible not autoplay', 50, {}, false],
30
+ ])('%s', (_, volume, playMetadata, shouldMount) => {
28
31
  beforeEach(() => {
29
32
  core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
30
33
  core.activeContainer.volume = volume
31
- core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', playMetadata)
34
+ core.activeContainer.emit(
35
+ Events.CONTAINER_PLAY,
36
+ 'Container',
37
+ playMetadata,
38
+ )
32
39
  })
33
40
  it(`should ${shouldMount ? 'mount' : 'not mount'} to container`, () => {
34
- expect(core.activeContainer.$el.find('#gplayer-big-mute-button').length).toBe(shouldMount ? 1 : 0)
41
+ expect(
42
+ core.activeContainer.$el.find('#gplayer-big-mute-button').length,
43
+ ).toBe(shouldMount ? 1 : 0)
35
44
  })
36
45
  })
37
46
  })
38
- })
47
+ describe('when playback is stopped', () => {
48
+ describe.each([
49
+ ['from ui', { ui: true }, true],
50
+ ['algorithmically', {}, false],
51
+ ])('%s', (_, stopMetadata, shouldUnmount) => {
52
+ beforeEach(() => {
53
+ core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
54
+ core.activeContainer.volume = 0
55
+ core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', {
56
+ autoPlay: true,
57
+ })
58
+ core.activeContainer.emit(
59
+ Events.CONTAINER_STOP,
60
+ 'Container',
61
+ stopMetadata,
62
+ )
63
+ })
64
+ it(`should ${shouldUnmount ? 'unmount' : 'not unmount'}`, () => {
65
+ expect(
66
+ core.activeContainer.$el.find('#gplayer-big-mute-button').length,
67
+ ).toBe(shouldUnmount ? 0 : 1)
68
+ })
69
+ })
70
+ })
71
+ describe('when playback is paused', () => {
72
+ beforeEach(() => {
73
+ core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
74
+ core.activeContainer.volume = 0
75
+ core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', {
76
+ autoPlay: true,
77
+ })
78
+ core.activeContainer.emit(Events.CONTAINER_PAUSE, 'Container')
79
+ })
80
+ it('should unmount', () => {
81
+ expect(
82
+ core.activeContainer.$el.find('#gplayer-big-mute-button').length,
83
+ ).toBe(0)
84
+ })
85
+ })
86
+ })
@@ -85,7 +85,7 @@ export class ClickToPause extends ContainerPlugin {
85
85
  const isPlaying = this.container && this.container.isPlaying()
86
86
 
87
87
  if (isPlaying) {
88
- useStop ? this.container.stop() : this.container.pause()
88
+ useStop ? this.container.stop({ ui: true }) : this.container.pause()
89
89
  } else {
90
90
  this.container.play()
91
91
  }
@@ -723,7 +723,7 @@ export class MediaControl extends UICorePlugin {
723
723
  }
724
724
 
725
725
  private togglePlayStop() {
726
- this.container.isPlaying() ? this.container.stop() : this.container.play()
726
+ this.container.isPlaying() ? this.container.stop({ ui: true }) : this.container.play()
727
727
  }
728
728
 
729
729
  private startSeekDrag(event: MouseEvent) {
@@ -135,6 +135,7 @@ export class SeekTime extends UICorePlugin {
135
135
  this.update()
136
136
  }
137
137
 
138
+ // TODO delegate calculation to the MediaControl plugin
138
139
  private calculateHoverPosition(event: MouseEvent) {
139
140
  const mediaControl = this.core.getPlugin('media_control')
140
141
  const offset = event.pageX - mediaControl.$seekBarContainer.offset().left
@@ -217,7 +217,9 @@ export class SourceController extends CorePlugin {
217
217
  if (this.switching) {
218
218
  return
219
219
  }
220
- this.autoPlay = !!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay
220
+ // The autoPlay metadata flag is set between a call to play and the actual playback start event, after which the flag is cleared.
221
+ this.autoPlay =
222
+ !!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay
221
223
  switch (error.code) {
222
224
  case PlaybackErrorCode.MediaSourceUnavailable:
223
225
  this.core.activeContainer?.getPlugin('poster')?.disable()
@@ -242,7 +244,7 @@ export class SourceController extends CorePlugin {
242
244
  this.listenTo(
243
245
  this.core.activeContainer,
244
246
  Events.CONTAINER_PLAY,
245
- (_: string, { autoPlay }: { autoPlay?: boolean}) => {
247
+ (_: string, { autoPlay }: { autoPlay?: boolean }) => {
246
248
  trace(`${T} onContainerPlay`, {
247
249
  autoPlay,
248
250
  })
package/src/testUtils.ts CHANGED
@@ -42,7 +42,10 @@ export function createSpinnerPlugin() {
42
42
  })
43
43
  }
44
44
 
45
- export function createMockPlayback(name = 'mock', options: Record<string, unknown> = {}) {
45
+ export function createMockPlayback(
46
+ name = 'mock',
47
+ options: Record<string, unknown> = {},
48
+ ) {
46
49
  const emitter = new Events()
47
50
  return Object.assign(emitter, {
48
51
  name,