@gcorevideo/player 2.20.17 → 2.20.19

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.17";
37252
+ var version$1 = "2.20.19";
37253
37253
 
37254
37254
  var packages = {
37255
37255
  "node_modules/@clappr/core": {
@@ -1,11 +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;
8
10
  _onWaiting(): void;
9
11
  _onEnded(): void;
12
+ _handleBufferingEvents(): void;
13
+ _onPlaying(): void;
10
14
  }
11
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;IAyBlD,UAAU;IAKV,QAAQ;CAIlB"}
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;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;IAyBtB,UAAU;CAQpB"}
@@ -1,8 +1,12 @@
1
+ import { PlayerError } from '@clappr/core';
1
2
  import { PlaybackErrorCode } from '../playback.types.js';
2
3
  import { BasePlayback } from './BasePlayback.js';
3
4
  import { trace } from '@gcorevideo/utils';
4
5
  const T = 'playback.html5_video';
6
+ const STALL_TIMEOUT = 15000;
5
7
  export default class HTML5Video extends BasePlayback {
8
+ stallTimerId = null;
9
+ statllTimerId = null;
6
10
  /**
7
11
  * @internal
8
12
  */
@@ -32,6 +36,42 @@ export default class HTML5Video extends BasePlayback {
32
36
  }
33
37
  _onEnded() {
34
38
  trace(`${T} _onEnded`);
39
+ if (this.stallTimerId) {
40
+ clearTimeout(this.stallTimerId);
41
+ this.stallTimerId = null;
42
+ }
35
43
  super._onEnded();
36
44
  }
45
+ _handleBufferingEvents() {
46
+ trace(`${T} _handleBufferingEvents`, {
47
+ networkState: this.el.networkState,
48
+ });
49
+ if (!this.statllTimerId) {
50
+ this.statllTimerId = setTimeout(() => {
51
+ trace(`${T} _handleBufferingEvents stall timeout`, {
52
+ buffering: this.buffering,
53
+ ended: this.ended,
54
+ isPlaying: this.isPlaying,
55
+ });
56
+ this.statllTimerId = null;
57
+ if (!this.isPlaying) {
58
+ this.createError({
59
+ code: PlaybackErrorCode.MediaSourceUnavailable,
60
+ level: PlayerError.Levels.FATAL,
61
+ message: 'Stall timeout',
62
+ description: 'Playback stalled for too long',
63
+ });
64
+ }
65
+ }, STALL_TIMEOUT);
66
+ }
67
+ super._handleBufferingEvents();
68
+ }
69
+ _onPlaying() {
70
+ trace(`${T} _onPlaying`);
71
+ if (this.stallTimerId) {
72
+ clearTimeout(this.stallTimerId);
73
+ this.stallTimerId = null;
74
+ }
75
+ super._onPlaying();
76
+ }
37
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.20.17",
3
+ "version": "2.20.19",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,12 +1,19 @@
1
+ import { PlayerError } from '@clappr/core'
1
2
  import { ErrorOptions } from '@clappr/core'
2
3
 
3
4
  import { PlaybackErrorCode } from '../playback.types.js'
4
5
  import { BasePlayback } from './BasePlayback.js'
5
6
  import { trace } from '@gcorevideo/utils'
7
+ import { TimerId } from '../utils/types.js'
6
8
 
7
9
  const T = 'playback.html5_video'
8
10
 
11
+ const STALL_TIMEOUT = 15000
12
+
9
13
  export default class HTML5Video extends BasePlayback {
14
+ private stallTimerId: TimerId | null = null
15
+ private statllTimerId: NodeJS.Timeout | null = null
16
+
10
17
  /**
11
18
  * @internal
12
19
  */
@@ -42,6 +49,44 @@ export default class HTML5Video extends BasePlayback {
42
49
 
43
50
  override _onEnded() {
44
51
  trace(`${T} _onEnded`)
52
+ if (this.stallTimerId) {
53
+ clearTimeout(this.stallTimerId)
54
+ this.stallTimerId = null
55
+ }
45
56
  super._onEnded()
46
57
  }
58
+
59
+ override _handleBufferingEvents() {
60
+ trace(`${T} _handleBufferingEvents`, {
61
+ networkState: (this.el as HTMLMediaElement).networkState,
62
+ })
63
+ if (!this.statllTimerId) {
64
+ this.statllTimerId = setTimeout(() => {
65
+ trace(`${T} _handleBufferingEvents stall timeout`, {
66
+ buffering: this.buffering,
67
+ ended: this.ended,
68
+ isPlaying: this.isPlaying,
69
+ })
70
+ this.statllTimerId = null
71
+ if (!this.isPlaying) {
72
+ this.createError({
73
+ code: PlaybackErrorCode.MediaSourceUnavailable,
74
+ level: PlayerError.Levels.FATAL,
75
+ message: 'Stall timeout',
76
+ description: 'Playback stalled for too long',
77
+ })
78
+ }
79
+ }, STALL_TIMEOUT)
80
+ }
81
+ super._handleBufferingEvents()
82
+ }
83
+
84
+ override _onPlaying() {
85
+ trace(`${T} _onPlaying`)
86
+ if (this.stallTimerId) {
87
+ clearTimeout(this.stallTimerId)
88
+ this.stallTimerId = null
89
+ }
90
+ super._onPlaying()
91
+ }
47
92
  }