@gcorevideo/player 2.26.9 → 2.27.0

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.
@@ -42579,6 +42579,7 @@ class HTML5Video extends BasePlayback {
42579
42579
  super._onEnded();
42580
42580
  }
42581
42581
  _handleBufferingEvents() {
42582
+ // TODO use the logic from the base class to detect if it's stalled or resumed, because in the latter case the current behavior is not correct
42582
42583
  if (!this.stallTimerId) {
42583
42584
  this.stallTimerId = setTimeout(() => {
42584
42585
  this.stallTimerId = null;
@@ -45407,13 +45408,16 @@ class CmcdConfig extends CorePlugin {
45407
45408
  constructor(core) {
45408
45409
  super(core);
45409
45410
  this.sid = this.options.cmcd?.sessionId ?? generateSessionId();
45410
- this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
45411
+ this.setContentId();
45411
45412
  }
45412
45413
  /**
45413
45414
  * @internal
45414
45415
  */
45415
45416
  bindEvents() {
45416
- this.listenTo(this.core, Events$1.CORE_CONTAINERS_CREATED, () => this.updateSettings(this.core.containers[0]));
45417
+ this.listenTo(this.core, Events$1.CORE_CONTAINERS_CREATED, () => {
45418
+ this.setContentId();
45419
+ this.updateSettings(this.core.containers[0]);
45420
+ });
45417
45421
  }
45418
45422
  /**
45419
45423
  * Returns the current `sid` and `cid` values.
@@ -45438,7 +45442,7 @@ class CmcdConfig extends CorePlugin {
45438
45442
  sid: this.sid,
45439
45443
  cid: this.cid,
45440
45444
  },
45441
- }
45445
+ },
45442
45446
  },
45443
45447
  });
45444
45448
  break;
@@ -45460,6 +45464,9 @@ class CmcdConfig extends CorePlugin {
45460
45464
  generateContentId() {
45461
45465
  return new URL(this.core.options.source ?? this.core.options.sources[0].source).pathname.slice(0, 64);
45462
45466
  }
45467
+ setContentId() {
45468
+ this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
45469
+ }
45463
45470
  }
45464
45471
 
45465
45472
  var mousetrap = {exports: {}};
@@ -49934,9 +49941,6 @@ function noSync(cb) {
49934
49941
  *
49935
49942
  * ```
49936
49943
  *
49937
- * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
49938
- * It is supposed to work autonomously.
49939
- *
49940
49944
  * @example
49941
49945
  * ```ts
49942
49946
  * import { SourceController } from '@gcorevideo/player'
@@ -50012,11 +50016,24 @@ class SourceController extends CorePlugin {
50012
50016
  if (this.core.options.source !== undefined) {
50013
50017
  // prevent Clappr from loading all sources simultaneously
50014
50018
  this.core.options.sources = [this.core.options.source];
50019
+ this.core.options.source = undefined; // TODO test
50015
50020
  }
50016
50021
  else {
50017
50022
  this.core.options.sources = this.core.options.sources.slice(0, 1);
50018
50023
  }
50019
50024
  }
50025
+ /**
50026
+ * Set new media source.
50027
+ *
50028
+ * @param sourcesList - The list of new media source URLs
50029
+ * @beta
50030
+ * @remarks
50031
+ * Triggers a reload of the playback module, container and all container plugins.
50032
+ */
50033
+ setMediaSource(sourcesList) {
50034
+ this.sourcesList = sourcesList;
50035
+ this.core.load(sourcesList, this.core.options.mimeType);
50036
+ }
50020
50037
  /**
50021
50038
  * @internal
50022
50039
  */
package/dist/index.js CHANGED
@@ -42740,6 +42740,7 @@ class HTML5Video extends BasePlayback {
42740
42740
  super._onEnded();
42741
42741
  }
42742
42742
  _handleBufferingEvents() {
42743
+ // TODO use the logic from the base class to detect if it's stalled or resumed, because in the latter case the current behavior is not correct
42743
42744
  if (!this.stallTimerId) {
42744
42745
  this.stallTimerId = setTimeout(() => {
42745
42746
  this.stallTimerId = null;
@@ -43265,7 +43266,7 @@ class Player {
43265
43266
  }
43266
43267
  }
43267
43268
 
43268
- var version$1 = "2.26.9";
43269
+ var version$1 = "2.27.0";
43269
43270
 
43270
43271
  var packages = {
43271
43272
  "node_modules/@clappr/core": {
@@ -45843,13 +45844,16 @@ class CmcdConfig extends CorePlugin {
45843
45844
  constructor(core) {
45844
45845
  super(core);
45845
45846
  this.sid = this.options.cmcd?.sessionId ?? generateSessionId();
45846
- this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
45847
+ this.setContentId();
45847
45848
  }
45848
45849
  /**
45849
45850
  * @internal
45850
45851
  */
45851
45852
  bindEvents() {
45852
- this.listenTo(this.core, Events$1.CORE_CONTAINERS_CREATED, () => this.updateSettings(this.core.containers[0]));
45853
+ this.listenTo(this.core, Events$1.CORE_CONTAINERS_CREATED, () => {
45854
+ this.setContentId();
45855
+ this.updateSettings(this.core.containers[0]);
45856
+ });
45853
45857
  }
45854
45858
  /**
45855
45859
  * Returns the current `sid` and `cid` values.
@@ -45874,7 +45878,7 @@ class CmcdConfig extends CorePlugin {
45874
45878
  sid: this.sid,
45875
45879
  cid: this.cid,
45876
45880
  },
45877
- }
45881
+ },
45878
45882
  },
45879
45883
  });
45880
45884
  break;
@@ -45896,6 +45900,9 @@ class CmcdConfig extends CorePlugin {
45896
45900
  generateContentId() {
45897
45901
  return new URL(this.core.options.source ?? this.core.options.sources[0].source).pathname.slice(0, 64);
45898
45902
  }
45903
+ setContentId() {
45904
+ this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
45905
+ }
45899
45906
  }
45900
45907
 
45901
45908
  var mousetrap = {exports: {}};
@@ -51283,9 +51290,6 @@ function noSync(cb) {
51283
51290
  *
51284
51291
  * ```
51285
51292
  *
51286
- * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
51287
- * It is supposed to work autonomously.
51288
- *
51289
51293
  * @example
51290
51294
  * ```ts
51291
51295
  * import { SourceController } from '@gcorevideo/player'
@@ -51361,11 +51365,24 @@ class SourceController extends CorePlugin {
51361
51365
  if (this.core.options.source !== undefined) {
51362
51366
  // prevent Clappr from loading all sources simultaneously
51363
51367
  this.core.options.sources = [this.core.options.source];
51368
+ this.core.options.source = undefined; // TODO test
51364
51369
  }
51365
51370
  else {
51366
51371
  this.core.options.sources = this.core.options.sources.slice(0, 1);
51367
51372
  }
51368
51373
  }
51374
+ /**
51375
+ * Set new media source.
51376
+ *
51377
+ * @param sourcesList - The list of new media source URLs
51378
+ * @beta
51379
+ * @remarks
51380
+ * Triggers a reload of the playback module, container and all container plugins.
51381
+ */
51382
+ setMediaSource(sourcesList) {
51383
+ this.sourcesList = sourcesList;
51384
+ this.core.load(sourcesList, this.core.options.mimeType);
51385
+ }
51369
51386
  /**
51370
51387
  * @internal
51371
51388
  */
package/dist/player.d.ts CHANGED
@@ -777,6 +777,7 @@ export declare class ClapprStats extends ContainerPlugin {
777
777
  };
778
778
  private updateSettings;
779
779
  private generateContentId;
780
+ private setContentId;
780
781
  }
781
782
 
782
783
  /**
@@ -2808,9 +2809,6 @@ export declare class ClapprStats extends ContainerPlugin {
2808
2809
  *
2809
2810
  * ```
2810
2811
  *
2811
- * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
2812
- * It is supposed to work autonomously.
2813
- *
2814
2812
  * @example
2815
2813
  * ```ts
2816
2814
  * import { SourceController } from '@gcorevideo/player'
@@ -2840,6 +2838,15 @@ export declare class ClapprStats extends ContainerPlugin {
2840
2838
  * @param core - The Clappr core instance.
2841
2839
  */
2842
2840
  constructor(core: Core);
2841
+ /**
2842
+ * Set new media source.
2843
+ *
2844
+ * @param sourcesList - The list of new media source URLs
2845
+ * @beta
2846
+ * @remarks
2847
+ * Triggers a reload of the playback module, container and all container plugins.
2848
+ */
2849
+ setMediaSource(sourcesList: PlayerMediaSourceDesc[]): void;
2843
2850
  /**
2844
2851
  * @internal
2845
2852
  */
@@ -52,7 +52,6 @@ sources_list:
52
52
  +-------------------+
53
53
 
54
54
  ```
55
- This plugin does not expose any public methods apart from required by the Clappr plugin interface. It is supposed to work autonomously.
56
55
 
57
56
  ## Example
58
57
 
@@ -94,5 +93,39 @@ Description
94
93
  Constructs a new instance of the `SourceController` class
95
94
 
96
95
 
96
+ </td></tr>
97
+ </tbody></table>
98
+
99
+ ## Methods
100
+
101
+ <table><thead><tr><th>
102
+
103
+ Method
104
+
105
+
106
+ </th><th>
107
+
108
+ Modifiers
109
+
110
+
111
+ </th><th>
112
+
113
+ Description
114
+
115
+
116
+ </th></tr></thead>
117
+ <tbody><tr><td>
118
+
119
+ [setMediaSource(sourcesList)](./player.sourcecontroller.setmediasource.md)
120
+
121
+
122
+ </td><td>
123
+
124
+
125
+ </td><td>
126
+
127
+ **_(BETA)_** Set new media source.
128
+
129
+
97
130
  </td></tr>
98
131
  </tbody></table>
@@ -0,0 +1,60 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [SourceController](./player.sourcecontroller.md) &gt; [setMediaSource](./player.sourcecontroller.setmediasource.md)
4
+
5
+ ## SourceController.setMediaSource() method
6
+
7
+ > This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
8
+ >
9
+
10
+ Set new media source.
11
+
12
+ **Signature:**
13
+
14
+ ```typescript
15
+ setMediaSource(sourcesList: PlayerMediaSourceDesc[]): void;
16
+ ```
17
+
18
+ ## Parameters
19
+
20
+ <table><thead><tr><th>
21
+
22
+ Parameter
23
+
24
+
25
+ </th><th>
26
+
27
+ Type
28
+
29
+
30
+ </th><th>
31
+
32
+ Description
33
+
34
+
35
+ </th></tr></thead>
36
+ <tbody><tr><td>
37
+
38
+ sourcesList
39
+
40
+
41
+ </td><td>
42
+
43
+ [PlayerMediaSourceDesc](./player.playermediasourcedesc.md)<!-- -->\[\]
44
+
45
+
46
+ </td><td>
47
+
48
+ The list of new media source URLs
49
+
50
+
51
+ </td></tr>
52
+ </tbody></table>
53
+ **Returns:**
54
+
55
+ void
56
+
57
+ ## Remarks
58
+
59
+ Triggers a reload of the playback module, container and all container plugins.
60
+
@@ -1 +1 @@
1
- {"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,aAAa,EAEb,uBAAuB,EACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE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AAgC;IAE1D,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,UAAU;YAMJ,MAAM;IAkBpB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,MAAM,CAgCb;IAED,OAAO,CAAC,gBAAgB;IAyCxB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,iBAAiB;CA+B1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTML5Video.d.ts","sourceRoot":"","sources":["../../src/playback/HTML5Video.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AAMzE,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,YAAY;IAClD,OAAO,CAAC,YAAY,CAAuB;IAE3C;;OAEG;IACM,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;IAkBlD,UAAU;IAIV,QAAQ;IAQR,sBAAsB;IAiBtB,UAAU;IAQV,QAAQ;IAQjB,IAAI,WAAW,IAAI,UAAU,EAAE,CAgB9B;IAGD,IAAI,iBAAiB,sBAiBpB;IAED,gBAAgB,CAAC,EAAE,EAAE,MAAM;CAa5B"}
1
+ {"version":3,"file":"HTML5Video.d.ts","sourceRoot":"","sources":["../../src/playback/HTML5Video.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AAMzE,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,YAAY;IAClD,OAAO,CAAC,YAAY,CAAuB;IAE3C;;OAEG;IACM,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;IAkBlD,UAAU;IAIV,QAAQ;IAQR,sBAAsB;IAkBtB,UAAU;IAQV,QAAQ;IAQjB,IAAI,WAAW,IAAI,UAAU,EAAE,CAgB9B;IAGD,IAAI,iBAAiB,sBAiBpB;IAED,gBAAgB,CAAC,EAAE,EAAE,MAAM;CAa5B"}
@@ -33,6 +33,7 @@ export default class HTML5Video extends BasePlayback {
33
33
  super._onEnded();
34
34
  }
35
35
  _handleBufferingEvents() {
36
+ // TODO use the logic from the base class to detect if it's stalled or resumed, because in the latter case the current behavior is not correct
36
37
  if (!this.stallTimerId) {
37
38
  this.stallTimerId = setTimeout(() => {
38
39
  this.stallTimerId = null;
@@ -64,5 +64,6 @@ export declare class CmcdConfig extends CorePlugin {
64
64
  };
65
65
  private updateSettings;
66
66
  private generateContentId;
67
+ private setContentId;
67
68
  }
68
69
  //# sourceMappingURL=CmcdConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CmcdConfig.d.ts","sourceRoot":"","sources":["../../../src/plugins/cmcd-config/CmcdConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,UAAU,EAAU,MAAM,cAAc,CAAA;AA4BrE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,OAAO,CAAC,GAAG,CAAQ;IAEnB,OAAO,CAAC,GAAG,CAAK;IAEhB;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,OAAO,WAEV;IAED;;OAEG;IACH,IAAI,gBAAgB,WAEnB;gBAEW,IAAI,EAAE,IAAI;IAMtB;;OAEG;IACM,UAAU;IAMnB;;;;OAIG;IACH,SAAS,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;YAO3B,cAAc;IAgC5B,OAAO,CAAC,iBAAiB;CAK1B"}
1
+ {"version":3,"file":"CmcdConfig.d.ts","sourceRoot":"","sources":["../../../src/plugins/cmcd-config/CmcdConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,UAAU,EAAU,MAAM,cAAc,CAAA;AA4BrE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,OAAO,CAAC,GAAG,CAAQ;IAEnB,OAAO,CAAC,GAAG,CAAK;IAEhB;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,OAAO,WAEV;IAED;;OAEG;IACH,IAAI,gBAAgB,WAEnB;gBAEW,IAAI,EAAE,IAAI;IAMtB;;OAEG;IACM,UAAU;IAOnB;;;;OAIG;IACH,SAAS,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;YAO3B,cAAc;IAgC5B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,YAAY;CAGrB"}
@@ -66,13 +66,16 @@ export class CmcdConfig extends CorePlugin {
66
66
  constructor(core) {
67
67
  super(core);
68
68
  this.sid = this.options.cmcd?.sessionId ?? generateSessionId();
69
- this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
69
+ this.setContentId();
70
70
  }
71
71
  /**
72
72
  * @internal
73
73
  */
74
74
  bindEvents() {
75
- this.listenTo(this.core, Events.CORE_CONTAINERS_CREATED, () => this.updateSettings(this.core.containers[0]));
75
+ this.listenTo(this.core, Events.CORE_CONTAINERS_CREATED, () => {
76
+ this.setContentId();
77
+ this.updateSettings(this.core.containers[0]);
78
+ });
76
79
  }
77
80
  /**
78
81
  * Returns the current `sid` and `cid` values.
@@ -97,7 +100,7 @@ export class CmcdConfig extends CorePlugin {
97
100
  sid: this.sid,
98
101
  cid: this.cid,
99
102
  },
100
- }
103
+ },
101
104
  },
102
105
  });
103
106
  break;
@@ -119,4 +122,7 @@ export class CmcdConfig extends CorePlugin {
119
122
  generateContentId() {
120
123
  return new URL(this.core.options.source ?? this.core.options.sources[0].source).pathname.slice(0, 64);
121
124
  }
125
+ setContentId() {
126
+ this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
127
+ }
122
128
  }
@@ -1,4 +1,5 @@
1
1
  import { CorePlugin, type Core as ClapprCore } from '@clappr/core';
2
+ import { type PlayerMediaSourceDesc } from '../../types.js';
2
3
  /**
3
4
  * `PLUGIN` that is managing the automatic failover between media sources.
4
5
  * @public
@@ -42,9 +43,6 @@ import { CorePlugin, type Core as ClapprCore } from '@clappr/core';
42
43
  *
43
44
  * ```
44
45
  *
45
- * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
46
- * It is supposed to work autonomously.
47
- *
48
46
  * @example
49
47
  * ```ts
50
48
  * import { SourceController } from '@gcorevideo/player'
@@ -74,6 +72,15 @@ export declare class SourceController extends CorePlugin {
74
72
  * @param core - The Clappr core instance.
75
73
  */
76
74
  constructor(core: ClapprCore);
75
+ /**
76
+ * Set new media source.
77
+ *
78
+ * @param sourcesList - The list of new media source URLs
79
+ * @beta
80
+ * @remarks
81
+ * Triggers a reload of the playback module, container and all container plugins.
82
+ */
83
+ setMediaSource(sourcesList: PlayerMediaSourceDesc[]): void;
77
84
  /**
78
85
  * @internal
79
86
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SourceController.d.ts","sourceRoot":"","sources":["../../../src/plugins/source-controller/SourceController.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,KAAK,IAAI,IAAI,UAAU,EACxB,MAAM,cA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,OAAO,CAAC,IAAI,CAAiB;IAE7B;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED;;OAEG;gBACS,IAAI,EAAE,UAAU;IAY5B;;;;;;;OAOG;IACH,cAAc,CAAC,WAAW,EAAE,qBAAqB,EAAE;IAKnD;;OAEG;IACM,UAAU;IAWnB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,wBAAwB;IAgBhC,OAAO,CAAC,2BAA2B;IAiDnC,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,MAAM,KAAK,OAAO,WAEjB;CACF"}
@@ -54,9 +54,6 @@ function noSync(cb) {
54
54
  *
55
55
  * ```
56
56
  *
57
- * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
58
- * It is supposed to work autonomously.
59
- *
60
57
  * @example
61
58
  * ```ts
62
59
  * import { SourceController } from '@gcorevideo/player'
@@ -132,11 +129,24 @@ export class SourceController extends CorePlugin {
132
129
  if (this.core.options.source !== undefined) {
133
130
  // prevent Clappr from loading all sources simultaneously
134
131
  this.core.options.sources = [this.core.options.source];
132
+ this.core.options.source = undefined; // TODO test
135
133
  }
136
134
  else {
137
135
  this.core.options.sources = this.core.options.sources.slice(0, 1);
138
136
  }
139
137
  }
138
+ /**
139
+ * Set new media source.
140
+ *
141
+ * @param sourcesList - The list of new media source URLs
142
+ * @beta
143
+ * @remarks
144
+ * Triggers a reload of the playback module, container and all container plugins.
145
+ */
146
+ setMediaSource(sourcesList) {
147
+ this.sourcesList = sourcesList;
148
+ this.core.load(sourcesList, this.core.options.mimeType);
149
+ }
140
150
  /**
141
151
  * @internal
142
152
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.26.9",
3
+ "version": "2.27.0",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/Player.ts CHANGED
@@ -367,7 +367,9 @@ export class Player {
367
367
  * @param name - name of the plugin
368
368
  */
369
369
  static unregisterPlugin(name: string) {
370
- Player.corePlugins = Player.corePlugins.filter((p) => p.prototype.name !== name)
370
+ Player.corePlugins = Player.corePlugins.filter(
371
+ (p) => p.prototype.name !== name,
372
+ )
371
373
  Loader.unregisterPlugin(name)
372
374
  }
373
375
 
@@ -48,6 +48,7 @@ export default class HTML5Video extends BasePlayback {
48
48
  }
49
49
 
50
50
  override _handleBufferingEvents() {
51
+ // TODO use the logic from the base class to detect if it's stalled or resumed, because in the latter case the current behavior is not correct
51
52
  if (!this.stallTimerId) {
52
53
  this.stallTimerId = setTimeout(() => {
53
54
  this.stallTimerId = null
@@ -92,16 +92,17 @@ export class CmcdConfig extends CorePlugin {
92
92
  constructor(core: Core) {
93
93
  super(core)
94
94
  this.sid = this.options.cmcd?.sessionId ?? generateSessionId()
95
- this.cid = this.options.cmcd?.contentId ?? this.generateContentId()
95
+ this.setContentId()
96
96
  }
97
97
 
98
98
  /**
99
99
  * @internal
100
100
  */
101
101
  override bindEvents() {
102
- this.listenTo(this.core, Events.CORE_CONTAINERS_CREATED, () =>
103
- this.updateSettings(this.core.containers[0]),
104
- )
102
+ this.listenTo(this.core, Events.CORE_CONTAINERS_CREATED, () => {
103
+ this.setContentId()
104
+ this.updateSettings(this.core.containers[0])
105
+ })
105
106
  }
106
107
 
107
108
  /**
@@ -128,7 +129,7 @@ export class CmcdConfig extends CorePlugin {
128
129
  sid: this.sid,
129
130
  cid: this.cid,
130
131
  },
131
- }
132
+ },
132
133
  },
133
134
  })
134
135
  break
@@ -153,4 +154,8 @@ export class CmcdConfig extends CorePlugin {
153
154
  this.core.options.source ?? this.core.options.sources[0].source,
154
155
  ).pathname.slice(0, 64)
155
156
  }
157
+
158
+ private setContentId() {
159
+ this.cid = this.options.cmcd?.contentId ?? this.generateContentId()
160
+ }
156
161
  }
@@ -69,9 +69,6 @@ function noSync(cb: () => void) {
69
69
  *
70
70
  * ```
71
71
  *
72
- * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
73
- * It is supposed to work autonomously.
74
- *
75
72
  * @example
76
73
  * ```ts
77
74
  * import { SourceController } from '@gcorevideo/player'
@@ -156,11 +153,25 @@ export class SourceController extends CorePlugin {
156
153
  if (this.core.options.source !== undefined) {
157
154
  // prevent Clappr from loading all sources simultaneously
158
155
  this.core.options.sources = [this.core.options.source]
156
+ this.core.options.source = undefined // TODO test
159
157
  } else {
160
158
  this.core.options.sources = this.core.options.sources.slice(0, 1)
161
159
  }
162
160
  }
163
161
 
162
+ /**
163
+ * Set new media source.
164
+ *
165
+ * @param sourcesList - The list of new media source URLs
166
+ * @beta
167
+ * @remarks
168
+ * Triggers a reload of the playback module, container and all container plugins.
169
+ */
170
+ setMediaSource(sourcesList: PlayerMediaSourceDesc[]) {
171
+ this.sourcesList = sourcesList
172
+ this.core.load(sourcesList, this.core.options.mimeType)
173
+ }
174
+
164
175
  /**
165
176
  * @internal
166
177
  */
@@ -8501,7 +8501,7 @@
8501
8501
  {
8502
8502
  "kind": "Class",
8503
8503
  "canonicalReference": "@gcorevideo/player!SourceController:class",
8504
- "docComment": "/**\n * `PLUGIN` that is managing the automatic failover between media sources.\n *\n * @remarks\n *\n * Have a look at the {@link https://miro.com/app/board/uXjVLiN15tY=/?share_link_id=390327585787 | source failover diagram} for the details on how sources ordering and selection works. Below is a simplified diagram:\n * ```markdown\n * sources_list:\n * - a.mpd | +--------------------+\n * - b.m3u8 |--->| init |\n * - ... | |--------------------|\n * | current_source = 0 |\n * +--------------------+\n * |\n * | source = a.mpd\n * | playback = dash.js\n * v\n * +------------------+\n * +-->| load source |\n * | +---------|--------+\n * | v\n * | +------------------+\n * | | play |\n * | +---------|--------+\n * | |\n * | v\n * | +-----------------------+\n * | | on playback_error |\n * | |-----------------------|\n * | | current_source = |\n * | | (current_source + 1) |\n * | | % len sources_list |\n * | | |\n * | | delay 1..3s |\n * | +---------------|-------+\n * | |\n * | source=b.m3u8 |\n * | playback=hls.js |\n * +-------------------+\n *\n * ```\n *\n * This plugin does not expose any public methods apart from required by the Clappr plugin interface. It is supposed to work autonomously.\n *\n * @example\n * ```ts\n * import { SourceController } from '@gcorevideo/player'\n *\n * Player.registerPlugin(SourceController)\n * ```\n *\n * @public\n */\n",
8504
+ "docComment": "/**\n * `PLUGIN` that is managing the automatic failover between media sources.\n *\n * @remarks\n *\n * Have a look at the {@link https://miro.com/app/board/uXjVLiN15tY=/?share_link_id=390327585787 | source failover diagram} for the details on how sources ordering and selection works. Below is a simplified diagram:\n * ```markdown\n * sources_list:\n * - a.mpd | +--------------------+\n * - b.m3u8 |--->| init |\n * - ... | |--------------------|\n * | current_source = 0 |\n * +--------------------+\n * |\n * | source = a.mpd\n * | playback = dash.js\n * v\n * +------------------+\n * +-->| load source |\n * | +---------|--------+\n * | v\n * | +------------------+\n * | | play |\n * | +---------|--------+\n * | |\n * | v\n * | +-----------------------+\n * | | on playback_error |\n * | |-----------------------|\n * | | current_source = |\n * | | (current_source + 1) |\n * | | % len sources_list |\n * | | |\n * | | delay 1..3s |\n * | +---------------|-------+\n * | |\n * | source=b.m3u8 |\n * | playback=hls.js |\n * +-------------------+\n *\n * ```\n *\n * @example\n * ```ts\n * import { SourceController } from '@gcorevideo/player'\n *\n * Player.registerPlugin(SourceController)\n * ```\n *\n * @public\n */\n",
8505
8505
  "excerptTokens": [
8506
8506
  {
8507
8507
  "kind": "Content",
@@ -8555,6 +8555,59 @@
8555
8555
  "isOptional": false
8556
8556
  }
8557
8557
  ]
8558
+ },
8559
+ {
8560
+ "kind": "Method",
8561
+ "canonicalReference": "@gcorevideo/player!SourceController#setMediaSource:member(1)",
8562
+ "docComment": "/**\n * Set new media source.\n *\n * @remarks\n *\n * Triggers a reload of the playback module, container and all container plugins.\n *\n * @param sourcesList - The list of new media source URLs\n *\n * @beta\n */\n",
8563
+ "excerptTokens": [
8564
+ {
8565
+ "kind": "Content",
8566
+ "text": "setMediaSource(sourcesList: "
8567
+ },
8568
+ {
8569
+ "kind": "Reference",
8570
+ "text": "PlayerMediaSourceDesc",
8571
+ "canonicalReference": "@gcorevideo/player!PlayerMediaSourceDesc:interface"
8572
+ },
8573
+ {
8574
+ "kind": "Content",
8575
+ "text": "[]"
8576
+ },
8577
+ {
8578
+ "kind": "Content",
8579
+ "text": "): "
8580
+ },
8581
+ {
8582
+ "kind": "Content",
8583
+ "text": "void"
8584
+ },
8585
+ {
8586
+ "kind": "Content",
8587
+ "text": ";"
8588
+ }
8589
+ ],
8590
+ "isStatic": false,
8591
+ "returnTypeTokenRange": {
8592
+ "startIndex": 4,
8593
+ "endIndex": 5
8594
+ },
8595
+ "releaseTag": "Beta",
8596
+ "isProtected": false,
8597
+ "overloadIndex": 1,
8598
+ "parameters": [
8599
+ {
8600
+ "parameterName": "sourcesList",
8601
+ "parameterTypeTokenRange": {
8602
+ "startIndex": 1,
8603
+ "endIndex": 3
8604
+ },
8605
+ "isOptional": false
8606
+ }
8607
+ ],
8608
+ "isOptional": false,
8609
+ "isAbstract": false,
8610
+ "name": "setMediaSource"
8558
8611
  }
8559
8612
  ],
8560
8613
  "extendsTokenRange": {