@gcorevideo/player 2.20.16 → 2.20.18

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.
@@ -37249,7 +37249,7 @@ class ClipsPlugin extends UICorePlugin {
37249
37249
 
37250
37250
  const templateHtml$1 = "<ul class=\"context-menu-list\">\n <% if(options) { %>\n <% for (var i = 0; i < options.length; i++) { %>\n <li class=\"context-menu-list-item <%= options[i].class %>\"\n data-<%= options[i].name %>><%= options[i].label %></li>\n <% } %>\n <% } %>\n</ul>\n";
37251
37251
 
37252
- var version$1 = "2.20.16";
37252
+ var version$1 = "2.20.18";
37253
37253
 
37254
37254
  var packages = {
37255
37255
  "node_modules/@clappr/core": {
@@ -1,9 +1,15 @@
1
1
  import { ErrorOptions } from '@clappr/core';
2
2
  import { BasePlayback } from './BasePlayback.js';
3
3
  export default class HTML5Video extends BasePlayback {
4
+ private stallTimerId;
5
+ private statllTimerId;
4
6
  /**
5
7
  * @internal
6
8
  */
7
9
  createError(errorData: any, options?: ErrorOptions): Error;
10
+ _onWaiting(): void;
11
+ _onEnded(): void;
12
+ _handleBufferingEvents(): void;
13
+ _onPlaying(): void;
8
14
  }
9
15
  //# sourceMappingURL=HTML5Video.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTML5Video.d.ts","sourceRoot":"","sources":["../../src/playback/HTML5Video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKhD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,YAAY;IAClD;;OAEG;IACM,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;CAwB5D"}
1
+ {"version":3,"file":"HTML5Video.d.ts","sourceRoot":"","sources":["../../src/playback/HTML5Video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAQhD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,YAAY;IAClD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,aAAa,CAA8B;IAEnD;;OAEG;IACM,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;IAyBlD,UAAU;IAKV,QAAQ;IASR,sBAAsB;IAuBtB,UAAU;CAQpB"}
@@ -2,13 +2,16 @@ import { PlaybackErrorCode } from '../playback.types.js';
2
2
  import { BasePlayback } from './BasePlayback.js';
3
3
  import { trace } from '@gcorevideo/utils';
4
4
  const T = 'playback.html5_video';
5
+ const STALL_TIMEOUT = 15000;
5
6
  export default class HTML5Video extends BasePlayback {
7
+ stallTimerId = null;
8
+ statllTimerId = null;
6
9
  /**
7
10
  * @internal
8
11
  */
9
12
  createError(errorData, options) {
10
13
  trace(`${T} createError`, {
11
- errorData: structuredClone(errorData),
14
+ errorData: { ...errorData },
12
15
  });
13
16
  const i18n = this.i18n ||
14
17
  // @ts-ignore
@@ -26,4 +29,46 @@ export default class HTML5Video extends BasePlayback {
26
29
  }
27
30
  return super.createError(errorData, { ...options, useCodePrefix: false });
28
31
  }
32
+ _onWaiting() {
33
+ trace(`${T} _onWaiting`);
34
+ super._onWaiting();
35
+ }
36
+ _onEnded() {
37
+ trace(`${T} _onEnded`);
38
+ if (this.stallTimerId) {
39
+ clearTimeout(this.stallTimerId);
40
+ this.stallTimerId = null;
41
+ }
42
+ super._onEnded();
43
+ }
44
+ _handleBufferingEvents() {
45
+ trace(`${T} _handleBufferingEvents`, {
46
+ networkState: this.el.networkState,
47
+ });
48
+ if (!this.statllTimerId) {
49
+ this.statllTimerId = setTimeout(() => {
50
+ trace(`${T} _handleBufferingEvents stall timeout`, {
51
+ buffering: this.buffering,
52
+ ended: this.ended,
53
+ isPlaying: this.isPlaying,
54
+ });
55
+ this.statllTimerId = null;
56
+ if (!this.isPlaying) {
57
+ this.createError({
58
+ code: PlaybackErrorCode.MediaSourceUnavailable,
59
+ message: 'Stall timeout',
60
+ });
61
+ }
62
+ }, STALL_TIMEOUT);
63
+ }
64
+ super._handleBufferingEvents();
65
+ }
66
+ _onPlaying() {
67
+ trace(`${T} _onPlaying`);
68
+ if (this.stallTimerId) {
69
+ clearTimeout(this.stallTimerId);
70
+ this.stallTimerId = null;
71
+ }
72
+ super._onPlaying();
73
+ }
29
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.20.16",
3
+ "version": "2.20.18",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -3,16 +3,22 @@ import { ErrorOptions } from '@clappr/core'
3
3
  import { PlaybackErrorCode } from '../playback.types.js'
4
4
  import { BasePlayback } from './BasePlayback.js'
5
5
  import { trace } from '@gcorevideo/utils'
6
+ import { TimerId } from '../utils/types.js'
6
7
 
7
8
  const T = 'playback.html5_video'
8
9
 
10
+ const STALL_TIMEOUT = 15000
11
+
9
12
  export default class HTML5Video extends BasePlayback {
13
+ private stallTimerId: TimerId | null = null
14
+ private statllTimerId: NodeJS.Timeout | null = null
15
+
10
16
  /**
11
17
  * @internal
12
18
  */
13
19
  override createError(errorData: any, options?: ErrorOptions) {
14
20
  trace(`${T} createError`, {
15
- errorData: structuredClone(errorData),
21
+ errorData: { ...errorData },
16
22
  })
17
23
  const i18n =
18
24
  this.i18n ||
@@ -34,4 +40,50 @@ export default class HTML5Video extends BasePlayback {
34
40
  }
35
41
  return super.createError(errorData, { ...options, useCodePrefix: false })
36
42
  }
43
+
44
+ override _onWaiting() {
45
+ trace(`${T} _onWaiting`)
46
+ super._onWaiting()
47
+ }
48
+
49
+ override _onEnded() {
50
+ trace(`${T} _onEnded`)
51
+ if (this.stallTimerId) {
52
+ clearTimeout(this.stallTimerId)
53
+ this.stallTimerId = null
54
+ }
55
+ super._onEnded()
56
+ }
57
+
58
+ override _handleBufferingEvents() {
59
+ trace(`${T} _handleBufferingEvents`, {
60
+ networkState: (this.el as HTMLMediaElement).networkState,
61
+ })
62
+ if (!this.statllTimerId) {
63
+ this.statllTimerId = setTimeout(() => {
64
+ trace(`${T} _handleBufferingEvents stall timeout`, {
65
+ buffering: this.buffering,
66
+ ended: this.ended,
67
+ isPlaying: this.isPlaying,
68
+ })
69
+ this.statllTimerId = null
70
+ if (!this.isPlaying) {
71
+ this.createError({
72
+ code: PlaybackErrorCode.MediaSourceUnavailable,
73
+ message: 'Stall timeout',
74
+ })
75
+ }
76
+ }, STALL_TIMEOUT)
77
+ }
78
+ super._handleBufferingEvents()
79
+ }
80
+
81
+ override _onPlaying() {
82
+ trace(`${T} _onPlaying`)
83
+ if (this.stallTimerId) {
84
+ clearTimeout(this.stallTimerId)
85
+ this.stallTimerId = null
86
+ }
87
+ super._onPlaying()
88
+ }
37
89
  }