@srgssr/pillarbox-web 1.19.1 → 1.20.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.
@@ -110,7 +110,7 @@
110
110
  return target;
111
111
  }
112
112
 
113
- const version$8 = "1.19.0";
113
+ const version$8 = "1.19.1";
114
114
 
115
115
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
116
116
 
@@ -73207,6 +73207,17 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73207
73207
  return PillarboxMonitoring.secondsToMilliseconds(bufferDuration);
73208
73208
  }
73209
73209
 
73210
+ /**
73211
+ * Gets the language of the current audio track.
73212
+ *
73213
+ * @returns {string|undefined} The language of the current audio track, or undefined if no audio track is available or if the language is not set.
73214
+ */
73215
+ currentAudioTrack() {
73216
+ const audioTrack = this.player.audioTrack();
73217
+ if (!audioTrack || !audioTrack.language) return;
73218
+ return audioTrack.language;
73219
+ }
73220
+
73210
73221
  /**
73211
73222
  * Get the current representation when playing a Dash or Hls media.
73212
73223
  *
@@ -73272,22 +73283,37 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73272
73283
  return this.player.currentSource().mediaData;
73273
73284
  }
73274
73285
 
73286
+ /**
73287
+ * Gets the language of the current text track (subtitles or captions).
73288
+ *
73289
+ * @returns {string|undefined} The language of the current text track, or undefined if no text track is available or if the language is not set.
73290
+ */
73291
+ currentTextTrack() {
73292
+ const textTrack = this.player.textTrack();
73293
+ if (!textTrack || !textTrack.language) return;
73294
+ return textTrack.language;
73295
+ }
73296
+
73275
73297
  /**
73276
73298
  * Handles player errors by sending an `ERROR` event, then resets the session.
73277
73299
  */
73278
73300
  error() {
73301
+ const audio = this.currentAudioTrack();
73279
73302
  const error = this.player.error();
73280
73303
  const playbackPosition = this.playbackPosition();
73281
73304
  const representation = this.currentRepresentation();
73282
73305
  const url = representation ? representation.uri : this.player.currentSource().src;
73306
+ const subtitles = this.currentTextTrack();
73283
73307
  if (!this.player.hasStarted()) {
73284
73308
  this.sendEvent('START', this.startEventData());
73285
73309
  }
73286
73310
  this.sendEvent('ERROR', _objectSpread2(_objectSpread2({
73311
+ audio,
73287
73312
  log: JSON.stringify(error.metadata || pillarbox.log.history().slice(-15)),
73288
73313
  message: error.message,
73289
73314
  name: PillarboxMonitoring.errorKeyCode(error.code)
73290
73315
  }, playbackPosition), {}, {
73316
+ subtitles,
73291
73317
  url
73292
73318
  }));
73293
73319
  this.reset();
@@ -73721,6 +73747,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73721
73747
  * @returns {StatusEventData} The current event data
73722
73748
  */
73723
73749
  statusEventData() {
73750
+ const audio = this.currentAudioTrack();
73724
73751
  const bandwidth = this.bandwidth();
73725
73752
  const buffered_duration = this.bufferDuration();
73726
73753
  const {
@@ -73737,7 +73764,9 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73737
73764
  } = this.playbackPosition();
73738
73765
  const stream_type = isFinite(this.player.duration()) ? 'On-demand' : 'Live';
73739
73766
  const stall = this.stallInfo();
73767
+ const subtitles = this.currentTextTrack();
73740
73768
  const data = {
73769
+ audio,
73741
73770
  bandwidth,
73742
73771
  bitrate,
73743
73772
  buffered_duration,
@@ -73747,6 +73776,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73747
73776
  position_timestamp,
73748
73777
  stall,
73749
73778
  stream_type,
73779
+ subtitles,
73750
73780
  url
73751
73781
  };
73752
73782
  return data;