@gcorevideo/player 2.28.25 → 2.28.27

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 (143) hide show
  1. package/dist/core.js +166 -61
  2. package/dist/index.css +395 -395
  3. package/dist/index.embed.js +155 -66
  4. package/dist/index.js +355 -151
  5. package/lib/Player.d.ts.map +1 -1
  6. package/lib/index.core.d.ts +1 -1
  7. package/lib/index.core.d.ts.map +1 -1
  8. package/lib/index.core.js +1 -1
  9. package/lib/index.plugins.d.ts +34 -34
  10. package/lib/index.plugins.d.ts.map +1 -1
  11. package/lib/index.plugins.js +34 -34
  12. package/lib/playback/types.d.ts.map +1 -1
  13. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  14. package/lib/plugins/bottom-gear/BottomGear.js +3 -1
  15. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
  16. package/lib/plugins/clappr-nerd-stats/speedtest/index.js +9 -5
  17. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -1
  18. package/lib/plugins/clappr-nerd-stats/utils.d.ts +2 -2
  19. package/lib/plugins/clips/utils.d.ts.map +1 -1
  20. package/lib/plugins/cmcd-config/CmcdConfig.js +1 -1
  21. package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
  22. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -1
  23. package/lib/plugins/google-analytics/GoogleAnalytics.js +10 -3
  24. package/lib/plugins/kibo/index.d.ts.map +1 -1
  25. package/lib/plugins/kibo/index.js +69 -20
  26. package/lib/plugins/level-selector/QualityLevels.js +2 -2
  27. package/lib/plugins/logo/Logo.d.ts.map +1 -1
  28. package/lib/plugins/logo/Logo.js +19 -15
  29. package/lib/plugins/logo/utils/index.d.ts.map +1 -1
  30. package/lib/plugins/logo/utils/index.js +11 -7
  31. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  32. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
  33. package/lib/plugins/multi-camera/MultiCamera.js +42 -20
  34. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  35. package/lib/plugins/picture-in-picture/PictureInPicture.js +3 -2
  36. package/lib/plugins/share/Share.d.ts.map +1 -1
  37. package/lib/plugins/share/Share.js +17 -12
  38. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
  39. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  40. package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
  41. package/lib/plugins/subtitles/ClosedCaptions.js +4 -3
  42. package/lib/plugins/thumbnails/Thumbnails.js +2 -3
  43. package/lib/plugins/thumbnails/utils.d.ts.map +1 -1
  44. package/lib/plugins/utils/fullscreen.d.ts.map +1 -1
  45. package/lib/plugins/utils.d.ts.map +1 -1
  46. package/lib/plugins/utils.js +1 -1
  47. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -1
  48. package/lib/plugins/vast-ads/VastAds.js +2 -1
  49. package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -1
  50. package/lib/plugins/vast-ads/loaderxml.js +8 -5
  51. package/lib/plugins/vast-ads/roll.d.ts +2 -2
  52. package/lib/plugins/vast-ads/roll.d.ts.map +1 -1
  53. package/lib/plugins/vast-ads/roll.js +16 -10
  54. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -1
  55. package/lib/plugins/vast-ads/rollmanager.js +17 -7
  56. package/lib/plugins/vast-ads/sctemanager.d.ts +1 -1
  57. package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -1
  58. package/lib/plugins/vast-ads/sctemanager.js +6 -5
  59. package/lib/plugins/vast-ads/types.d.ts.map +1 -1
  60. package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -1
  61. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -1
  62. package/lib/plugins/vast-ads/xmlhttprequest.js +3 -2
  63. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -1
  64. package/lib/plugins/vast-ads/xmlmerge.js +4 -3
  65. package/lib/types.d.ts +1 -1
  66. package/lib/types.d.ts.map +1 -1
  67. package/lib/utils/clickaway.d.ts.map +1 -1
  68. package/lib/utils/mediaSources.d.ts.map +1 -1
  69. package/lib/utils/mediaSources.js +1 -3
  70. package/lib/utils/types.d.ts.map +1 -1
  71. package/lib/version.js +2 -2
  72. package/package.json +3 -3
  73. package/src/Player.ts +10 -10
  74. package/src/__tests__/Player.test.ts +33 -10
  75. package/src/index.core.ts +10 -1
  76. package/src/index.plugins.ts +35 -35
  77. package/src/playback/BasePlayback.ts +1 -1
  78. package/src/playback/__tests__/HTML5Video.test.ts +10 -4
  79. package/src/playback/dash-playback/__tests__/DashPlayback.test.ts +10 -38
  80. package/src/playback/hls-playback/__tests__/HlsPlayback.test.ts +12 -45
  81. package/src/playback/types.ts +0 -1
  82. package/src/playback.types.ts +1 -2
  83. package/src/plugins/audio-selector/AudioTracks.ts +1 -1
  84. package/src/plugins/audio-selector/__tests__/AudioTracks.test.ts +30 -11
  85. package/src/plugins/bottom-gear/BottomGear.ts +3 -2
  86. package/src/plugins/clappr-nerd-stats/NerdStats.ts +1 -1
  87. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +104 -82
  88. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +3 -3
  89. package/src/plugins/clappr-nerd-stats/utils.ts +2 -2
  90. package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +30 -18
  91. package/src/plugins/clips/utils.ts +5 -1
  92. package/src/plugins/cmcd-config/CmcdConfig.ts +1 -1
  93. package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +21 -15
  94. package/src/plugins/favicon/Favicon.ts +73 -49
  95. package/src/plugins/google-analytics/GoogleAnalytics.ts +93 -58
  96. package/src/plugins/kibo/index.ts +183 -109
  97. package/src/plugins/level-selector/QualityLevels.ts +2 -2
  98. package/src/plugins/logo/Logo.ts +134 -105
  99. package/src/plugins/logo/utils/index.ts +27 -20
  100. package/src/plugins/media-control/MediaControl.ts +12 -6
  101. package/src/plugins/multi-camera/MultiCamera.ts +218 -157
  102. package/src/plugins/picture-in-picture/PictureInPicture.ts +41 -37
  103. package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +25 -11
  104. package/src/plugins/poster/__tests__/Poster.test.ts +8 -9
  105. package/src/plugins/share/Share.ts +85 -60
  106. package/src/plugins/skip-time/SkipTime.ts +5 -1
  107. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +8 -5
  108. package/src/plugins/subtitles/ClosedCaptions.ts +7 -5
  109. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +0 -1
  110. package/src/plugins/thumbnails/Thumbnails.ts +22 -21
  111. package/src/plugins/thumbnails/__tests__/Thumbnails.test.ts +14 -7
  112. package/src/plugins/thumbnails/utils.ts +3 -1
  113. package/src/plugins/typings/globals.d.ts +7 -7
  114. package/src/plugins/typings/workers.d.ts +3 -3
  115. package/src/plugins/utils/fullscreen.ts +2 -2
  116. package/src/plugins/utils.ts +17 -13
  117. package/src/plugins/vast-ads/VastAds.ts +4 -5
  118. package/src/plugins/vast-ads/loaderxml.ts +142 -101
  119. package/src/plugins/vast-ads/roll.ts +381 -284
  120. package/src/plugins/vast-ads/rollmanager.ts +214 -170
  121. package/src/plugins/vast-ads/sctemanager.ts +66 -48
  122. package/src/plugins/vast-ads/types.ts +15 -9
  123. package/src/plugins/vast-ads/urlhandler.ts +18 -13
  124. package/src/plugins/vast-ads/xmlhttprequest.ts +25 -20
  125. package/src/plugins/vast-ads/xmlmerge.ts +42 -32
  126. package/src/plugins/video360/VRControls.js +50 -42
  127. package/src/plugins/video360/VREffect.js +298 -206
  128. package/src/plugins/video360/Video360.js +553 -423
  129. package/src/plugins/video360/orbit-oriention-controls.js +526 -421
  130. package/src/plugins/video360/utils.js +18 -18
  131. package/src/types.ts +5 -3
  132. package/src/typings/@clappr/core/error_mixin.d.ts +9 -9
  133. package/src/typings/@clappr/core/index.d.ts +1 -3
  134. package/src/typings/@clappr/core/playback.d.ts +3 -3
  135. package/src/typings/@clappr/index.d.ts +1 -1
  136. package/src/typings/globals.d.ts +15 -15
  137. package/src/utils/__tests__/mediaSources.test.ts +42 -26
  138. package/src/utils/clickaway.ts +24 -24
  139. package/src/utils/errors.ts +2 -2
  140. package/src/utils/mediaSources.ts +5 -4
  141. package/src/utils/types.ts +1 -1
  142. package/src/version.ts +2 -2
  143. package/tsconfig.tsbuildinfo +1 -1
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- const APP_NAME = "gplayer";
1
+ const APP_NAME = '_';
2
2
  class DebuggerWrapper {
3
3
  writer;
4
4
  namespace;
@@ -15,19 +15,19 @@ class DebuggerWrapper {
15
15
  this.currentWriter = nullWriter;
16
16
  }
17
17
  write = (m, ...args) => {
18
- const tokens = args.map((_) => "%s");
19
- if (typeof m === "string" || args.length > 0) {
20
- tokens.unshift("%s");
18
+ const tokens = args.map((_) => '%s');
19
+ if (typeof m === 'string' || args.length > 0) {
20
+ tokens.unshift('%s');
21
21
  }
22
- this.currentWriter(`${this.namespace}: ${tokens.join(' ')}`, m, ...args.map(a => JSON.stringify(a)));
22
+ this.currentWriter(`${this.namespace}: ${tokens.join(' ')}`, m, ...args.map((a) => JSON.stringify(a)));
23
23
  };
24
24
  }
25
25
  const currentPatterns = [];
26
26
  function parsePattern(pattern) {
27
- if (pattern === "*") {
27
+ if (pattern === '*') {
28
28
  return /.?/;
29
29
  }
30
- return new RegExp("^" + pattern.replace(/\*/g, "[@\\w-]+"), "i");
30
+ return new RegExp('^' + pattern.replace(/\*/g, '[@\\w-]+'), 'i');
31
31
  }
32
32
  function pass(namespace) {
33
33
  return currentPatterns.some((p) => p.test(namespace));
@@ -43,8 +43,8 @@ let Logger$1 = class Logger {
43
43
  error;
44
44
  debug;
45
45
  static items = [];
46
- constructor(namespace, appName = APP_NAME) {
47
- const ns = namespace ? `:${namespace}` : "";
46
+ constructor(appName = APP_NAME, namespace = '') {
47
+ const ns = namespace ? `:${namespace}` : '';
48
48
  const info = new DebuggerWrapper(console.info.bind(console), `${appName}:INFO${ns}`, pass(namespace));
49
49
  this.info = info.write;
50
50
  const warn = new DebuggerWrapper(console.warn.bind(console), `${appName}:WARN${ns}`, pass(namespace));
@@ -62,7 +62,7 @@ let Logger$1 = class Logger {
62
62
  * @param patterns - comma-separated list of patterns, can contain '*' as a wildcard
63
63
  */
64
64
  static enable(patterns) {
65
- currentPatterns.splice(0, currentPatterns.length, ...patterns.split(",").filter(Boolean).map(parsePattern));
65
+ currentPatterns.splice(0, currentPatterns.length, ...patterns.split(',').filter(Boolean).map(parsePattern));
66
66
  Logger.toggleItems();
67
67
  }
68
68
  static disable() {
@@ -80,14 +80,35 @@ let Logger$1 = class Logger {
80
80
  }
81
81
  };
82
82
 
83
+ /**
84
+ * A tracer that pushes a record through a chain of tracers
85
+ * @beta
86
+ */
87
+ class ChainedTracer {
88
+ tracers;
89
+ constructor(tracers) {
90
+ this.tracers = tracers;
91
+ }
92
+ reportError(e) {
93
+ for (const tracer of this.tracers) {
94
+ tracer.reportError(e);
95
+ }
96
+ }
97
+ trace(msg, data) {
98
+ for (const tracer of this.tracers) {
99
+ tracer.trace(msg, data);
100
+ }
101
+ }
102
+ }
103
+
83
104
  /**
84
105
  * A tracer that logs to the console
85
106
  * @public
86
107
  */
87
108
  class LogTracer {
88
109
  logger;
89
- constructor(ns = "") {
90
- this.logger = new Logger$1(ns);
110
+ constructor(appName = '') {
111
+ this.logger = new Logger$1(appName);
91
112
  }
92
113
  reportError(e) {
93
114
  this.logger.error(e);
@@ -96,19 +117,73 @@ class LogTracer {
96
117
  this.logger.debug(msg, data);
97
118
  }
98
119
  }
99
- // export class LogTracer implements Tracer {
100
- // private tags: Record<string, TagValue> = {};
101
- // reportError(e: Error) {
102
- // logger.error(e, this.tags);
103
- // }
104
- // setTag(name: string, value: TagValue) {
105
- // this.tags[name] = value;
106
- // }
107
- // trace(msg: string, data?: Record<string, unknown>) {
108
- // const fullData = Object.assign({}, this.tags, data);
109
- // logger.debug(msg, fullData);
110
- // }
111
- // }
120
+
121
+ const DEFAULT_DELAY = 1000;
122
+ const MIN_DELAY = 1000;
123
+ /**
124
+ * A tracer the pushes the records to a remote server.
125
+ * Used with fullstack Node.js applications (Nuxt.js, Next.js, etc.)
126
+ * @beta
127
+ */
128
+ class RemoteTracer {
129
+ baseTracer;
130
+ tags;
131
+ buffer = [];
132
+ timerId = null;
133
+ delay;
134
+ /**
135
+ *
136
+ * @param baseTracer An additional tracer to be called next to this one. Deprecated. Use {@link ChainedTracer} instead.
137
+ * @param tags
138
+ * @param options
139
+ */
140
+ constructor(baseTracer, tags = {}, options = {}) {
141
+ this.baseTracer = baseTracer;
142
+ this.tags = tags;
143
+ this.delay = Math.max(options.delay ?? DEFAULT_DELAY, MIN_DELAY);
144
+ }
145
+ reportError(e) {
146
+ if (this.baseTracer) {
147
+ this.baseTracer.reportError(e);
148
+ }
149
+ const message = String(e);
150
+ const detail = e instanceof Error && 'detail' in e
151
+ ? e.detail
152
+ : undefined;
153
+ this.push(message, detail);
154
+ }
155
+ trace(message, detail) {
156
+ if (this.baseTracer) {
157
+ this.baseTracer.trace(message, detail);
158
+ }
159
+ this.push(message, detail);
160
+ }
161
+ setTag(key, value) {
162
+ this.tags[key] = value;
163
+ }
164
+ push(message, detail) {
165
+ const time = new Date().getTime();
166
+ this.buffer.push({ message, detail, time });
167
+ if (!this.timerId) {
168
+ this.timerId = setTimeout(() => {
169
+ this.timerId = null;
170
+ this.send(this.buffer.splice(0, this.buffer.length));
171
+ }, this.delay);
172
+ }
173
+ }
174
+ send(records) {
175
+ fetch('/api/traceb', {
176
+ method: 'POST',
177
+ body: JSON.stringify({
178
+ records,
179
+ tags: this.tags,
180
+ }),
181
+ headers: {
182
+ 'Content-Type': 'application/json',
183
+ },
184
+ }).catch((e) => console.error(e));
185
+ }
186
+ }
112
187
 
113
188
  /**
114
189
  * @beta
@@ -125,8 +200,8 @@ class SentryTracer {
125
200
  }
126
201
  trace(message, data) {
127
202
  this.scope.addBreadcrumb({
128
- type: "default",
129
- level: "info",
203
+ type: 'default',
204
+ level: 'info',
130
205
  message,
131
206
  data,
132
207
  });
@@ -12621,9 +12696,7 @@ function buildMediaSourcesList(sources, priorityTransport = 'dash') {
12621
12696
  }
12622
12697
  const [preferred, rest] = sources.reduce(([preferred, rest], item) => {
12623
12698
  for (const p of playbacks) {
12624
- if ([
12625
- 'html5_audio', 'html_img', 'no_op'
12626
- ].includes(p.prototype.name)) {
12699
+ if (['html5_audio', 'html_img', 'no_op'].includes(p.prototype.name)) {
12627
12700
  continue;
12628
12701
  }
12629
12702
  const canPlay = p.canPlay(item.source, item.mimeType);
@@ -13799,7 +13872,7 @@ function enableLogs(debugConfig, context, id) {
13799
13872
  // Some browsers don't allow to use bind on console object anyway
13800
13873
  // fallback to default if needed
13801
13874
  try {
13802
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.14"}`);
13875
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.15"}`);
13803
13876
  } catch (e) {
13804
13877
  /* log fn threw an exception. All logger methods are no-ops. */
13805
13878
  return createLogger();
@@ -18245,11 +18318,7 @@ class FragmentTracker {
18245
18318
  });
18246
18319
  fragmentEntity.loaded = null;
18247
18320
  if (Object.keys(fragmentEntity.range).length) {
18248
- fragmentEntity.buffered = true;
18249
- const endList = fragmentEntity.body.endList = frag.endList || fragmentEntity.body.endList;
18250
- if (endList) {
18251
- this.endListFragments[fragmentEntity.body.type] = fragmentEntity;
18252
- }
18321
+ this.bufferedEnd(fragmentEntity, frag);
18253
18322
  if (!isPartial(fragmentEntity)) {
18254
18323
  // Remove older fragment parts from lookup after frag is tracked as buffered
18255
18324
  this.removeParts(frag.sn - 1, frag.type);
@@ -18259,6 +18328,13 @@ class FragmentTracker {
18259
18328
  this.removeFragment(fragmentEntity.body);
18260
18329
  }
18261
18330
  }
18331
+ bufferedEnd(fragmentEntity, frag) {
18332
+ fragmentEntity.buffered = true;
18333
+ const endList = fragmentEntity.body.endList = frag.endList || fragmentEntity.body.endList;
18334
+ if (endList) {
18335
+ this.endListFragments[fragmentEntity.body.type] = fragmentEntity;
18336
+ }
18337
+ }
18262
18338
  removeParts(snToKeep, levelType) {
18263
18339
  const activeParts = this.activePartLists[levelType];
18264
18340
  if (!activeParts) {
@@ -18283,7 +18359,7 @@ class FragmentTracker {
18283
18359
  }
18284
18360
  if (fragmentEntity) {
18285
18361
  fragmentEntity.loaded = null;
18286
- fragmentEntity.buffered = true;
18362
+ this.bufferedEnd(fragmentEntity, frag);
18287
18363
  }
18288
18364
  }
18289
18365
  getBufferedTimes(fragment, part, partial, timeRange) {
@@ -20332,6 +20408,14 @@ class LevelKey {
20332
20408
  static setKeyIdForUri(uri, keyId) {
20333
20409
  keyUriToKeyIdMap[uri] = keyId;
20334
20410
  }
20411
+ static addKeyIdForUri(uri) {
20412
+ const val = Object.keys(keyUriToKeyIdMap).length % Number.MAX_SAFE_INTEGER;
20413
+ const keyId = new Uint8Array(16);
20414
+ const dv = new DataView(keyId.buffer, 12, 4); // Just set the last 4 bytes
20415
+ dv.setUint32(0, val);
20416
+ keyUriToKeyIdMap[uri] = keyId;
20417
+ return keyId;
20418
+ }
20335
20419
  constructor(method, uri, format, formatversions = [1], iv = null, keyId) {
20336
20420
  this.uri = void 0;
20337
20421
  this.method = void 0;
@@ -22496,7 +22580,7 @@ class BaseStreamController extends TaskLoop {
22496
22580
  this.state = State.FRAG_LOADING;
22497
22581
 
22498
22582
  // Load key before streaming fragment data
22499
- const dataOnProgress = this.config.progressive;
22583
+ const dataOnProgress = this.config.progressive && frag.type !== PlaylistLevelType.SUBTITLE;
22500
22584
  let result;
22501
22585
  if (dataOnProgress && keyLoadingPromise) {
22502
22586
  result = keyLoadingPromise.then(keyLoadedData => {
@@ -23344,11 +23428,12 @@ class BaseStreamController extends TaskLoop {
23344
23428
  }, false);
23345
23429
  if (!parsed) {
23346
23430
  var _this$transmuxer;
23347
- if (level.fragmentError === 0) {
23348
- // Mark and track the odd empty segment as a gap to avoid reloading
23431
+ const mediaNotFound = ((_this$transmuxer = this.transmuxer) == null ? void 0 : _this$transmuxer.error) === null;
23432
+ if (level.fragmentError === 0 || mediaNotFound && (level.fragmentError < 2 || frag.endList)) {
23433
+ // Mark and track the odd (or last) empty segment as a gap to avoid reloading
23349
23434
  this.treatAsGap(frag, level);
23350
23435
  }
23351
- if (((_this$transmuxer = this.transmuxer) == null ? void 0 : _this$transmuxer.error) === null) {
23436
+ if (mediaNotFound) {
23352
23437
  const error = new Error(`Found no media in fragment ${frag.sn} of ${this.playlistLabel()} ${frag.level} resetting transmuxer to fallback to playlist timing`);
23353
23438
  this.warn(error.message);
23354
23439
  this.hls.trigger(Events.ERROR, {
@@ -23809,7 +23894,7 @@ function requireEventemitter3 () {
23809
23894
  var eventemitter3Exports = requireEventemitter3();
23810
23895
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
23811
23896
 
23812
- const version$2 = "1.6.14";
23897
+ const version$2 = "1.6.15";
23813
23898
 
23814
23899
  // ensure the worker ends up in the bundle
23815
23900
  // If the worker should not be included this gets aliased to empty.js
@@ -28987,7 +29072,7 @@ class MP4Remuxer extends Logger {
28987
29072
  // Clear the track samples. This also clears the samples array in the demuxer, since the reference is shared
28988
29073
  track.samples = [];
28989
29074
  const start = (firstPTS - initTime) / inputTimeScale;
28990
- const end = nextAudioTs / inputTimeScale;
29075
+ const end = this.nextAudioTs / inputTimeScale;
28991
29076
  const type = 'audio';
28992
29077
  const audioData = {
28993
29078
  data1: moof,
@@ -36151,6 +36236,11 @@ class EMEController extends Logger {
36151
36236
  }
36152
36237
  const keyIdArray = 'buffer' in keyId ? new Uint8Array(keyId.buffer, keyId.byteOffset, keyId.byteLength) : new Uint8Array(keyId);
36153
36238
  if (mediaKeySessionContext.keySystem === KeySystems.PLAYREADY && keyIdArray.length === 16) {
36239
+ // On some devices, the key ID has already been converted for endianness.
36240
+ // In such cases, this key ID is the one we need to cache.
36241
+ const originKeyIdWithStatusChange = arrayToHex(keyIdArray);
36242
+ // Cache the original key IDs to ensure compatibility across all cases.
36243
+ keyStatuses[originKeyIdWithStatusChange] = status;
36154
36244
  changeEndianness(keyIdArray);
36155
36245
  }
36156
36246
  const keyIdWithStatusChange = arrayToHex(keyIdArray);
@@ -38492,7 +38582,8 @@ class InterstitialsController extends Logger {
38492
38582
  if (backwardSeek && currentTime < start || currentTime >= start + duration) {
38493
38583
  var _playingItem$event;
38494
38584
  if ((_playingItem$event = playingItem.event) != null && _playingItem$event.appendInPlace) {
38495
- this.clearInterstitial(playingItem.event, playingItem);
38585
+ // Return SourceBuffer(s) to primary player and flush
38586
+ this.clearAssetPlayers(playingItem.event, playingItem);
38496
38587
  this.flushFrontBuffer(currentTime);
38497
38588
  }
38498
38589
  this.setScheduleToAssetAtTime(currentTime, playingAsset);
@@ -40202,11 +40293,14 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))} pos: ${this.timeline
40202
40293
  return player;
40203
40294
  }
40204
40295
  clearInterstitial(interstitial, toSegment) {
40296
+ this.clearAssetPlayers(interstitial, toSegment);
40297
+ // Remove asset list and resolved duration
40298
+ interstitial.reset();
40299
+ }
40300
+ clearAssetPlayers(interstitial, toSegment) {
40205
40301
  interstitial.assetList.forEach(asset => {
40206
40302
  this.clearAssetPlayer(asset.identifier, toSegment);
40207
40303
  });
40208
- // Remove asset list and resolved duration
40209
- interstitial.reset();
40210
40304
  }
40211
40305
  resetAssetPlayer(assetId) {
40212
40306
  // Reset asset player so that it's timeline can be adjusted without reloading the MVP
@@ -40398,10 +40492,10 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))} pos: ${this.timeline
40398
40492
  // Fallback to Primary by on current or future events by updating schedule to skip errored interstitials/assets
40399
40493
  const flushStart = interstitial.timelineStart;
40400
40494
  const playingItem = this.effectivePlayingItem;
40495
+ let timelinePos = this.timelinePos;
40401
40496
  // Update schedule now that interstitial/assets are flagged with `error` for fallback
40402
40497
  if (playingItem) {
40403
- this.log(`Fallback to primary from event "${interstitial.identifier}" start: ${flushStart} pos: ${this.timelinePos} playing: ${segmentToString(playingItem)} error: ${interstitial.error}`);
40404
- let timelinePos = this.timelinePos;
40498
+ this.log(`Fallback to primary from event "${interstitial.identifier}" start: ${flushStart} pos: ${timelinePos} playing: ${segmentToString(playingItem)} error: ${interstitial.error}`);
40405
40499
  if (timelinePos === -1) {
40406
40500
  timelinePos = this.hls.startPosition;
40407
40501
  }
@@ -40413,14 +40507,15 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))} pos: ${this.timeline
40413
40507
  this.attachPrimary(flushStart, null);
40414
40508
  this.flushFrontBuffer(flushStart);
40415
40509
  }
40416
- if (!this.schedule) {
40417
- return;
40418
- }
40419
- const scheduleIndex = this.schedule.findItemIndexAtTime(timelinePos);
40420
- this.setSchedulePosition(scheduleIndex);
40421
- } else {
40510
+ } else if (timelinePos === -1) {
40422
40511
  this.checkStart();
40512
+ return;
40423
40513
  }
40514
+ if (!this.schedule) {
40515
+ return;
40516
+ }
40517
+ const scheduleIndex = this.schedule.findItemIndexAtTime(timelinePos);
40518
+ this.setSchedulePosition(scheduleIndex);
40424
40519
  }
40425
40520
 
40426
40521
  // Asset List loading
@@ -40461,7 +40556,8 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))} pos: ${this.timeline
40461
40556
  // Abandon if new duration is reduced enough to land playback in primary start
40462
40557
  const index = this.schedule.findItemIndexAtTime(this.timelinePos);
40463
40558
  if (index !== scheduleIndex) {
40464
- interstitial.error = new Error(`Interstitial no longer within playback range ${this.timelinePos} ${interstitial}`);
40559
+ interstitial.error = new Error(`Interstitial ${assets.length ? 'no longer within playback range' : 'asset-list is empty'} ${this.timelinePos} ${interstitial}`);
40560
+ this.log(interstitial.error.message);
40465
40561
  this.updateSchedule(true);
40466
40562
  this.primaryFallback(interstitial);
40467
40563
  return;
@@ -47269,7 +47365,7 @@ class StreamController extends BaseStreamController {
47269
47365
  onAudioTrackSwitching(event, data) {
47270
47366
  const hls = this.hls;
47271
47367
  // if any URL found on new audio track, it is an alternate audio track
47272
- const fromAltAudio = this.altAudio === 2;
47368
+ const fromAltAudio = this.altAudio !== 0;
47273
47369
  const altAudio = useAlternateAudio(data.url, hls);
47274
47370
  // if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
47275
47371
  // don't do anything if we switch to alt audio: audio stream controller is handling it.
@@ -47295,6 +47391,7 @@ class StreamController extends BaseStreamController {
47295
47391
  }
47296
47392
  // If switching from alt to main audio, flush all audio and trigger track switched
47297
47393
  if (fromAltAudio) {
47394
+ this.altAudio = 0;
47298
47395
  this.fragmentTracker.removeAllFragments();
47299
47396
  hls.once(Events.BUFFER_FLUSHED, () => {
47300
47397
  if (!this.hls) {
@@ -48132,14 +48229,22 @@ class KeyLoader extends Logger {
48132
48229
  if (!keyInfo.decryptdata.keyId && (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data) {
48133
48230
  const keyIds = parseKeyIdsFromTenc(frag.initSegment.data);
48134
48231
  if (keyIds.length) {
48135
- const keyId = keyIds[0];
48232
+ let keyId = keyIds[0];
48136
48233
  if (keyId.some(b => b !== 0)) {
48137
48234
  this.log(`Using keyId found in init segment ${arrayToHex(keyId)}`);
48138
- keyInfo.decryptdata.keyId = keyId;
48139
48235
  LevelKey.setKeyIdForUri(keyInfo.decryptdata.uri, keyId);
48236
+ } else {
48237
+ keyId = LevelKey.addKeyIdForUri(keyInfo.decryptdata.uri);
48238
+ this.log(`Generating keyId to patch media ${arrayToHex(keyId)}`);
48140
48239
  }
48240
+ keyInfo.decryptdata.keyId = keyId;
48141
48241
  }
48142
48242
  }
48243
+ if (!keyInfo.decryptdata.keyId && !isMediaFragment(frag)) {
48244
+ // Resolve so that unencrypted init segment is loaded
48245
+ // key id is extracted from tenc box when processing key for next segment above
48246
+ return Promise.resolve(keyLoadedData);
48247
+ }
48143
48248
  const keySessionContextPromise = this.emeController.loadKey(keyLoadedData);
48144
48249
  return (keyInfo.keyLoadPromise = keySessionContextPromise.then(keySessionContext => {
48145
48250
  keyInfo.mediaKeySessionContext = keySessionContext;
@@ -51326,7 +51431,7 @@ class Player {
51326
51431
  }
51327
51432
  }
51328
51433
 
51329
- var version$1 = "2.28.25";
51434
+ var version$1 = "2.28.27";
51330
51435
 
51331
51436
  var packages = {
51332
51437
  "node_modules/@clappr/core": {
@@ -51334,7 +51439,7 @@ var packages = {
51334
51439
  "node_modules/dashjs": {
51335
51440
  version: "4.7.4"},
51336
51441
  "node_modules/hls.js": {
51337
- version: "1.6.14"}};
51442
+ version: "1.6.15"}};
51338
51443
 
51339
51444
  /**
51340
51445
  * Version information about the gplayer and its main dependencies
@@ -51350,4 +51455,4 @@ function version() {
51350
51455
  };
51351
51456
  }
51352
51457
 
51353
- export { LogTracer, Logger$1 as Logger, PlaybackErrorCode, Player, PlayerEvent, SentryTracer, reportError, setTracer, trace, version };
51458
+ export { ChainedTracer, LogTracer, Logger$1 as Logger, PlaybackErrorCode, Player, PlayerEvent, RemoteTracer, SentryTracer, reportError, setTracer, trace, version };