@gcorevideo/player 2.20.11 → 2.20.13

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 (66) hide show
  1. package/dist/core.js +26 -2
  2. package/dist/index.css +953 -953
  3. package/dist/index.js +61 -55
  4. package/dist/player.d.ts +47 -15
  5. package/dist/plugins/index.css +1475 -1475
  6. package/dist/plugins/index.js +36 -49
  7. package/docs/api/player.contextmenupluginsettings.md +1 -1
  8. package/docs/api/player.favicon.md +4 -174
  9. package/docs/api/{player.favicon.bindevents.md → player.faviconpluginsettings.faviconcolor.md} +5 -7
  10. package/docs/api/{player.favicon._constructor_.md → player.faviconpluginsettings.md} +17 -8
  11. package/docs/api/player.md +15 -4
  12. package/docs/api/{player.favicon.disable.md → player.mediacontrol.getcenterpanel.md} +4 -4
  13. package/docs/api/{player.favicon.configure.md → player.mediacontrol.getleftpanel.md} +8 -4
  14. package/docs/api/player.mediacontrol.md +30 -11
  15. package/docs/api/player.playbackerror.md +2 -2
  16. package/docs/api/player.playbackerror.origin.md +1 -1
  17. package/docs/api/player.playbackerror.scope.md +1 -1
  18. package/docs/api/player.poster.md +1 -1
  19. package/docs/api/player.sourcecontroller.md +2 -33
  20. package/lib/Player.js +1 -1
  21. package/lib/playback/HTML5Video.d.ts +5 -0
  22. package/lib/playback/HTML5Video.d.ts.map +1 -1
  23. package/lib/playback/HTML5Video.js +21 -0
  24. package/lib/playback/hls-playback/HlsPlayback.d.ts +2 -2
  25. package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
  26. package/lib/playback/hls-playback/HlsPlayback.js +4 -0
  27. package/lib/playback.types.d.ts +2 -2
  28. package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
  29. package/lib/plugins/click-to-pause/ClickToPause.js +0 -4
  30. package/lib/plugins/context-menu/ContextMenu.d.ts +1 -1
  31. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
  32. package/lib/plugins/dvr-controls/DvrControls.js +0 -1
  33. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
  34. package/lib/plugins/error-screen/ErrorScreen.js +0 -1
  35. package/lib/plugins/favicon/Favicon.d.ts +30 -3
  36. package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
  37. package/lib/plugins/favicon/Favicon.js +28 -35
  38. package/lib/plugins/media-control/MediaControl.d.ts +1 -8
  39. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  40. package/lib/plugins/media-control/MediaControl.js +2 -9
  41. package/lib/plugins/poster/Poster.d.ts +2 -0
  42. package/lib/plugins/poster/Poster.d.ts.map +1 -1
  43. package/lib/plugins/poster/Poster.js +3 -3
  44. package/lib/plugins/source-controller/SourceController.d.ts +3 -0
  45. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  46. package/lib/plugins/source-controller/SourceController.js +3 -0
  47. package/package.json +1 -1
  48. package/src/Player.ts +1 -1
  49. package/src/playback/HTML5Video.ts +29 -1
  50. package/src/playback/__tests__/HTML5Video.test.ts +47 -0
  51. package/src/playback/hls-playback/HlsPlayback.ts +5 -1
  52. package/src/playback.types.ts +2 -2
  53. package/src/plugins/click-to-pause/ClickToPause.ts +0 -5
  54. package/src/plugins/context-menu/ContextMenu.ts +1 -1
  55. package/src/plugins/dvr-controls/DvrControls.ts +0 -1
  56. package/src/plugins/error-screen/ErrorScreen.ts +0 -1
  57. package/src/plugins/favicon/Favicon.ts +38 -41
  58. package/src/plugins/media-control/MediaControl.ts +2 -9
  59. package/src/plugins/poster/Poster.ts +4 -3
  60. package/src/plugins/source-controller/SourceController.ts +3 -0
  61. package/temp/player.api.json +101 -246
  62. package/tsconfig.tsbuildinfo +1 -1
  63. package/docs/api/player.favicon.destroy.md +0 -18
  64. package/docs/api/player.favicon.name.md +0 -14
  65. package/docs/api/player.favicon.supportedversion.md +0 -16
  66. package/docs/api/player.sourcecontroller._constructor_.md +0 -50
@@ -504,7 +504,7 @@ export default class HlsPlayback extends BasePlayback {
504
504
  this.trigger(Events.PLAYBACK_READY, this.name)
505
505
  }
506
506
 
507
- _recover(evt: HlsEvents.ERROR, data: HlsErrorData, error: PlaybackError) {
507
+ private _recover(evt: HlsEvents.ERROR, data: HlsErrorData, error: PlaybackError) {
508
508
  assert(this._hls, 'Hls.js instance is not available')
509
509
  if (!this._recoveredDecodingError) {
510
510
  this._recoveredDecodingError = true
@@ -690,6 +690,10 @@ export default class HlsPlayback extends BasePlayback {
690
690
  details: data.details,
691
691
  })
692
692
  error.level = PlayerError.Levels.WARN
693
+ // TODO check
694
+ // if (data.error instanceof MediaError && data.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) {
695
+ // error.code = PlaybackErrorCode.MediaSourceUnavailable
696
+ // }
693
697
  this._recover(evt, data, error)
694
698
  break
695
699
  default:
@@ -109,7 +109,7 @@ export interface PlaybackError {
109
109
  */
110
110
  message: string
111
111
  /**
112
- * Exact component that originated the error.
112
+ * Name of the component that originated the error.
113
113
  * @example
114
114
  * - 'core'
115
115
  * - 'dash'
@@ -117,7 +117,7 @@ export interface PlaybackError {
117
117
  */
118
118
  origin: string
119
119
  /**
120
- * Component subsystem of the error origin
120
+ * Component subsystem of the error origin, together with the `origin` uniquely identifies the originating component.
121
121
  */
122
122
  scope: PlayerComponentType
123
123
 
@@ -70,11 +70,6 @@ export class ClickToPause extends ContainerPlugin {
70
70
  const isLivePlayback = this.container.getPlaybackType() === Playback.LIVE
71
71
  const pointerEnabled = !isLivePlayback || this.container.isDvrEnabled()
72
72
 
73
- trace(`${T} settingsUpdate`, {
74
- isLivePlayback,
75
- pointerEnabled,
76
- })
77
-
78
73
  if (pointerEnabled === this.pointerEnabled) {
79
74
  return
80
75
  }
@@ -18,7 +18,7 @@ type MenuOption = {
18
18
  }
19
19
 
20
20
  /**
21
- * The plugin adds a context menu to the player.
21
+ * Context menu plugin settings
22
22
  * @beta
23
23
  */
24
24
  export interface ContextMenuPluginSettings {
@@ -129,7 +129,6 @@ export class DvrControls extends UICorePlugin {
129
129
  }
130
130
 
131
131
  private settingsUpdate() {
132
- trace(`${T} settingsUpdate`)
133
132
  this.core.getPlugin('media_control').$el.removeClass('live')
134
133
  this.render()
135
134
  }
@@ -154,7 +154,6 @@ export class ErrorScreen extends UICorePlugin {
154
154
  }),
155
155
  )
156
156
 
157
- // TODO append to container instead of core?
158
157
  if (!this.el.parentElement) {
159
158
  this.core.$el.append(this.el)
160
159
  }
@@ -10,15 +10,23 @@ import stopIcon from '../../../assets/icons/new/stop.svg';
10
10
  const FAVICON_COLOR = '#567';
11
11
  const FAVICON_SELECTOR = 'link[rel="shortcut icon"]';
12
12
 
13
- // const oldIcon = $(FAVICON_SELECTOR);
13
+ /**
14
+ * @beta
15
+ */
16
+ export interface FaviconPluginSettings {
17
+ /**
18
+ * CSS color of the favicon.
19
+ */
20
+ faviconColor?: string;
21
+ }
14
22
 
15
23
  /**
16
- * `PLUGIN` that adds custom favicon to the player's tab.
24
+ * `PLUGIN` that changes the favicon according to the player's state.
17
25
  * @beta
26
+ * @remarks
27
+ * There are three states: stopped, playing and paused.
18
28
  */
19
29
  export class Favicon extends CorePlugin {
20
- private _container: Container | null = null;
21
-
22
30
  private oldIcon: ZeptoResult;
23
31
 
24
32
  private playIcon: ZeptoResult | null = null;
@@ -27,18 +35,23 @@ export class Favicon extends CorePlugin {
27
35
 
28
36
  private stopIcon: ZeptoResult | null = null;
29
37
 
38
+ /**
39
+ * @internal
40
+ */
30
41
  get name() {
31
42
  return 'favicon';
32
43
  }
33
44
 
45
+ /**
46
+ * @internal
47
+ */
34
48
  get supportedVersion() {
35
49
  return { min: CLAPPR_VERSION };
36
50
  }
37
51
 
38
- // get oldIcon() {
39
- // return oldIcon;
40
- // }
41
-
52
+ /**
53
+ * @internal
54
+ */
42
55
  constructor(core: Core) {
43
56
  super(core);
44
57
  this.oldIcon = $(FAVICON_SELECTOR);
@@ -46,45 +59,35 @@ export class Favicon extends CorePlugin {
46
59
  this.stopIcon = this.createIcon(stopIcon);
47
60
  this.changeIcon(this.stopIcon);
48
61
  }
49
- this.configure();
50
- }
51
-
52
- configure() {
53
- if (this.core.options.changeFavicon) {
54
- if (!this.enabled) {
55
- // @ts-ignore
56
- this.stopListening(this.core, Events.CORE_OPTIONS_CHANGE);
57
- this.enable();
58
- }
59
- } else if (this.enabled) {
60
- this.disable();
61
- this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.configure);
62
- }
63
62
  }
64
63
 
64
+ /**
65
+ * @internal
66
+ */
65
67
  override bindEvents() {
66
- this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.configure);
67
68
  this.listenTo(this.core, Events.CORE_ACTIVE_CONTAINER_CHANGED, this.containerChanged);
68
- this.core.activeContainer && this.containerChanged();
69
69
  }
70
70
 
71
71
  private containerChanged() {
72
- // @ts-ignore
73
- this._container && this.stopListening(this._container);
74
- this._container = this.core.activeContainer;
75
- this.listenTo(this._container, Events.CONTAINER_PLAY, this.setPlayIcon);
76
- this.listenTo(this._container, Events.CONTAINER_PAUSE, this.setPauseIcon);
77
- this.listenTo(this._container, Events.CONTAINER_STOP, this.resetIcon);
78
- this.listenTo(this._container, Events.CONTAINER_ENDED, this.resetIcon);
79
- this.listenTo(this._container, Events.CONTAINER_ERROR, this.resetIcon);
72
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAY, this.setPlayIcon);
73
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_PAUSE, this.setPauseIcon);
74
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_STOP, this.resetIcon);
75
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_ENDED, this.resetIcon);
76
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_ERROR, this.resetIcon);
80
77
  this.resetIcon();
81
78
  }
82
79
 
80
+ /**
81
+ * @internal
82
+ */
83
83
  override disable() {
84
84
  super.disable();
85
85
  this.resetIcon();
86
86
  }
87
87
 
88
+ /**
89
+ * @internal
90
+ */
88
91
  override destroy() {
89
92
  super.destroy();
90
93
  this.resetIcon();
@@ -113,7 +116,6 @@ export class Favicon extends CorePlugin {
113
116
  if (!this.playIcon) {
114
117
  this.playIcon = this.createIcon(playIcon);
115
118
  }
116
-
117
119
  this.changeIcon(this.playIcon);
118
120
  }
119
121
 
@@ -121,21 +123,16 @@ export class Favicon extends CorePlugin {
121
123
  if (!this.pauseIcon) {
122
124
  this.pauseIcon = this.createIcon(pauseIcon);
123
125
  }
124
-
125
126
  this.changeIcon(this.pauseIcon);
126
127
  }
127
128
 
128
129
  private resetIcon() {
129
- $(FAVICON_SELECTOR).remove();
130
130
  const icon = this.oldIcon.length > 0 ? this.oldIcon : this.stopIcon;
131
-
132
131
  this.changeIcon(icon);
133
132
  }
134
133
 
135
- private changeIcon(icon: ZeptoResult | null) {
136
- if (icon) {
137
- $('link[rel="shortcut icon"]').remove();
138
- $('head').append(icon);
139
- }
134
+ private changeIcon(icon: ZeptoResult) {
135
+ $('link[rel="shortcut icon"]').remove();
136
+ $('head').append(icon);
140
137
  }
141
138
  }
@@ -19,6 +19,7 @@ import { reportError, trace } from '@gcorevideo/utils'
19
19
 
20
20
  import { type TimeProgress } from '../../playback.types.js'
21
21
 
22
+ // TODO replace Kibo with mousetrap
22
23
  import { Kibo } from '../kibo/index.js'
23
24
 
24
25
  import { CLAPPR_VERSION } from '../../build.js'
@@ -90,17 +91,10 @@ type DisabledClickable = {
90
91
  }
91
92
 
92
93
  /**
93
- * `PLUGIN` that provides a foundation for developing custom media controls UI.
94
+ * `PLUGIN` that provides basic playback controls UI and a foundation for developing custom UI.
94
95
  * @beta
95
96
  * @remarks
96
97
  * The methods exposed are to be used by the other plugins that extend the media control UI.
97
- * The plugin registration should be arranged so that MediaControl is initialized before every other `PLUGIN` that depends on it.
98
- * @example
99
- * ```ts
100
- * Player.registerPlugin(MediaControl) // <--- This must go first
101
- * Player.registerPlugin(LevelSelector) // a media control plugin
102
- * Player.registerPlugin(NerdStats) // another media control plugin
103
- * ```
104
98
  */
105
99
  export class MediaControl extends UICorePlugin {
106
100
  private advertisementPlaying = false
@@ -1316,7 +1310,6 @@ export class MediaControl extends UICorePlugin {
1316
1310
  }
1317
1311
 
1318
1312
  private configure() {
1319
- // this.advertisementPlaying ? this.disable() : this.enable()
1320
1313
  this.trigger(Events.MEDIACONTROL_OPTIONS_CHANGE)
1321
1314
  }
1322
1315
 
@@ -9,7 +9,6 @@ import {
9
9
  UIContainerPlugin,
10
10
  template,
11
11
  $,
12
- Container,
13
12
  } from '@clappr/core'
14
13
  import { trace } from '@gcorevideo/utils'
15
14
 
@@ -28,6 +27,8 @@ const T = 'plugins.poster'
28
27
  * @beta
29
28
  * @remarks
30
29
  * When the playback is stopped, media control UI is disabled.
30
+ * Note that the poster image, if specified via the player config, will be used to update video element's poster attribute by the
31
+ * HTML5-video-based playback module.
31
32
  *
32
33
  * Configuration options:
33
34
  *
@@ -51,6 +52,8 @@ const T = 'plugins.poster'
51
52
  * ```
52
53
  */
53
54
  export class Poster extends UIContainerPlugin {
55
+ // TODO merge non-poster related functionality into the ClickToPause plugin
56
+
54
57
  private hasFatalError = false
55
58
 
56
59
  private hasStartedPlaying = false
@@ -236,8 +239,6 @@ export class Poster extends UIContainerPlugin {
236
239
  this.container.playback.consent()
237
240
  this.container.playback.play()
238
241
  }
239
- } else {
240
- this.container.trigger('container:start')
241
242
  }
242
243
 
243
244
  return false
@@ -108,6 +108,9 @@ export class SourceController extends CorePlugin {
108
108
  return { min: CLAPPR_VERSION }
109
109
  }
110
110
 
111
+ /**
112
+ * @internal
113
+ */
111
114
  constructor(core: ClapprCore) {
112
115
  super(core)
113
116
  this.sourcesList = this.core.options.sources