@gcorevideo/player 2.28.28 → 2.28.29

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.
package/dist/index.js CHANGED
@@ -12954,6 +12954,8 @@ class DashPlayback extends BasePlayback {
12954
12954
  startChangeQuality = false;
12955
12955
  manifestInfo = null;
12956
12956
  _timeUpdateTimer = null;
12957
+ oncueenter = null;
12958
+ oncueexit = null;
12957
12959
  get name() {
12958
12960
  return 'dash';
12959
12961
  }
@@ -12996,6 +12998,7 @@ class DashPlayback extends BasePlayback {
12996
12998
  }
12997
12999
  }
12998
13000
  get _startTime() {
13001
+ // TODO review
12999
13002
  if (this._playbackType === Playback.LIVE &&
13000
13003
  this._playlistType !== 'EVENT') {
13001
13004
  return this._extrapolatedStartTime;
@@ -13050,12 +13053,12 @@ class DashPlayback extends BasePlayback {
13050
13053
  streaming: {
13051
13054
  text: {
13052
13055
  defaultEnabled: false,
13056
+ dispatchForManualRendering: true,
13053
13057
  },
13054
13058
  },
13055
13059
  }, this.options.dash);
13056
13060
  this._dash.updateSettings(settings);
13057
13061
  }
13058
- assert.ok(this.el instanceof HTMLMediaElement, 'el must be an HTMLMediaElement');
13059
13062
  this._dash.attachView(this.el);
13060
13063
  this._dash.setAutoPlay(false);
13061
13064
  this._dash.attachSource(this.options.src);
@@ -13099,6 +13102,19 @@ class DashPlayback extends BasePlayback {
13099
13102
  this.trigger(Events$1.PLAYBACK_AUDIO_CHANGED, toClapprTrack$1(e.newMediaInfo));
13100
13103
  }
13101
13104
  });
13105
+ this._dash.on(_.events.CUE_ENTER, (e) => {
13106
+ this.oncueenter?.({
13107
+ end: e.end,
13108
+ id: e.id,
13109
+ start: e.start,
13110
+ text: e.text,
13111
+ });
13112
+ });
13113
+ this._dash.on(_.events.CUE_EXIT, (e) => {
13114
+ this.oncueexit?.({
13115
+ id: e.id,
13116
+ });
13117
+ });
13102
13118
  }
13103
13119
  render() {
13104
13120
  this._ready();
@@ -13187,8 +13203,7 @@ class DashPlayback extends BasePlayback {
13187
13203
  this.trigger(Events$1.PLAYBACK_SETTINGSUPDATE);
13188
13204
  }
13189
13205
  _onPlaybackError = (event) => {
13190
- // TODO
13191
- trace(`${T$f} _onPlaybackError`, { event });
13206
+ trace(`${T$f} _onPlaybackError`, { type: event.type, code: event.error.code, message: event.error.message });
13192
13207
  };
13193
13208
  _onDASHJSSError = (event) => {
13194
13209
  this._stopTimeUpdateTimer();
@@ -13307,7 +13322,14 @@ class DashPlayback extends BasePlayback {
13307
13322
  this._dash.off(_.events.ERROR, this._onDASHJSSError);
13308
13323
  this._dash.off(_.events.PLAYBACK_ERROR, this._onPlaybackError);
13309
13324
  this._dash.off(_.events.MANIFEST_LOADED, this.getDuration);
13325
+ const tracks = this._dash.getTracksFor('text');
13326
+ tracks.forEach(track => {
13327
+ if (track.id) {
13328
+ this._dash.removeExternalSubtitleById(track.id);
13329
+ }
13330
+ });
13310
13331
  this._dash.reset();
13332
+ this._dash.destroy();
13311
13333
  this._dash = null;
13312
13334
  }
13313
13335
  }
@@ -13325,8 +13347,6 @@ class DashPlayback extends BasePlayback {
13325
13347
  }
13326
13348
  }
13327
13349
  _fillLevels(levels) {
13328
- // TOOD check that levels[i].index === i
13329
- trace(`${T$f} _fillLevels`, { levels });
13330
13350
  this._levels = levels.map((level) => {
13331
13351
  return {
13332
13352
  level: level.index,
@@ -13403,6 +13423,31 @@ class DashPlayback extends BasePlayback {
13403
13423
  super._handleTextTrackChange();
13404
13424
  this._dash?.setTextTrack(this.closedCaptionsTrackId);
13405
13425
  }
13426
+ setTextTrack(id) {
13427
+ this._dash?.setTextTrack(id);
13428
+ }
13429
+ /**
13430
+ * @override
13431
+ */
13432
+ get closedCaptionsTracks() {
13433
+ const tt = this.getTextTracks();
13434
+ return tt;
13435
+ }
13436
+ getTextTracks() {
13437
+ return this._dash?.getTracksFor('text').map((t, index) => ({
13438
+ id: index,
13439
+ name: getTextTrackLabel(t) || "",
13440
+ track: {
13441
+ id: index,
13442
+ label: getTextTrackLabel(t) || "",
13443
+ language: t.lang,
13444
+ mode: "hidden",
13445
+ },
13446
+ })) || [];
13447
+ }
13448
+ }
13449
+ function getTextTrackLabel(t) {
13450
+ return t.labels.find((l) => !l.lang || l.lang === t.lang)?.text;
13406
13451
  }
13407
13452
  DashPlayback.canPlay = function (resource, mimeType) {
13408
13453
  if (!isDashSource(resource, mimeType)) {
@@ -50057,11 +50102,9 @@ const CLAPPR_VERSION$1 = '0.13.0';
50057
50102
  const { now } = Utils;
50058
50103
  const AUTO = -1;
50059
50104
  const DEFAULT_RECOVER_ATTEMPTS = 16;
50060
- Events$1.register('PLAYBACK_FRAGMENT_CHANGED');
50061
50105
  Events$1.register('PLAYBACK_FRAGMENT_PARSING_METADATA');
50062
50106
  const T$e = 'playback.hls';
50063
50107
  class HlsPlayback extends BasePlayback {
50064
- _ccIsSetup = false;
50065
50108
  _ccTracksUpdated = false;
50066
50109
  _currentFragment = null;
50067
50110
  _currentLevel = null;
@@ -50085,6 +50128,10 @@ class HlsPlayback extends BasePlayback {
50085
50128
  _recoveredDecodingError = false;
50086
50129
  _segmentTargetDuration = null;
50087
50130
  _timeUpdateTimer = null;
50131
+ oncueenter = null;
50132
+ oncueexit = null;
50133
+ cues = []; // TODO check the list size and use BST if needed
50134
+ currentCueId = null;
50088
50135
  /**
50089
50136
  * @internal
50090
50137
  */
@@ -50279,7 +50326,7 @@ class HlsPlayback extends BasePlayback {
50279
50326
  return;
50280
50327
  }
50281
50328
  this._manifestParsed = false;
50282
- this._ccIsSetup = false;
50329
+ // this._ccIsSetup = false
50283
50330
  this._ccTracksUpdated = false;
50284
50331
  this._setInitialState();
50285
50332
  this._hls.destroy();
@@ -50290,6 +50337,7 @@ class HlsPlayback extends BasePlayback {
50290
50337
  maxBufferLength: 2,
50291
50338
  maxMaxBufferLength: 4,
50292
50339
  autoStartLoad: false,
50340
+ renderTextTracksNatively: false,
50293
50341
  }, this.options.playback.hlsjsConfig);
50294
50342
  this._hls = new Hls(config);
50295
50343
  }
@@ -50303,7 +50351,7 @@ class HlsPlayback extends BasePlayback {
50303
50351
  if (!this._hls) {
50304
50352
  return;
50305
50353
  }
50306
- this._hls.once(Hls.Events.MEDIA_ATTACHED, () => {
50354
+ this._hls.once(Events.MEDIA_ATTACHED, () => {
50307
50355
  assert.ok(this._hls, 'HLS.js is not initialized');
50308
50356
  this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src);
50309
50357
  });
@@ -50318,25 +50366,29 @@ class HlsPlayback extends BasePlayback {
50318
50366
  this.el.removeEventListener('playing', onPlaying);
50319
50367
  };
50320
50368
  this.el.addEventListener('playing', onPlaying);
50321
- this._hls.on(Hls.Events.MANIFEST_PARSED, () => {
50369
+ this._hls.on(Events.MANIFEST_PARSED, () => {
50322
50370
  this._manifestParsed = true;
50323
- this._hls.startLoad(-1);
50371
+ this.reload();
50324
50372
  });
50325
- this._hls.on(Hls.Events.LEVEL_LOADED, (evt, data) => {
50373
+ this._hls.on(Events.LEVEL_LOADED, (evt, data) => {
50326
50374
  this._updatePlaybackType(evt, data);
50327
50375
  });
50328
- this._hls.on(Hls.Events.LEVEL_UPDATED, (evt, data) => this._onLevelUpdated(evt, data));
50329
- this._hls.on(Hls.Events.LEVEL_SWITCHING, (evt, data) => this._onLevelSwitch(evt, data));
50330
- this._hls.on(Hls.Events.LEVEL_SWITCHED, (evt, data) => this._onLevelSwitched(evt, data));
50331
- this._hls.on(Hls.Events.FRAG_CHANGED, (evt, data) => this._onFragmentChanged(evt, data));
50332
- this._hls.on(Hls.Events.FRAG_LOADED, (evt, data) => this._onFragmentLoaded(evt, data));
50333
- this._hls.on(Hls.Events.FRAG_PARSING_METADATA, (evt, data) => this._onFragmentParsingMetadata(evt, data));
50334
- this._hls.on(Hls.Events.ERROR, (evt, data) => this._onHLSJSError(evt, data));
50335
- // this._hls.on(HLSJS.Events.SUBTITLE_TRACK_LOADED, () =>
50336
- // this._onSubtitleLoaded(),
50337
- // )
50376
+ this._hls.on(Events.LEVEL_UPDATED, (evt, data) => this._onLevelUpdated(evt, data));
50377
+ this._hls.on(Events.LEVEL_SWITCHING, (evt, data) => this._onLevelSwitch(evt, data));
50378
+ this._hls.on(Events.LEVEL_SWITCHED, (evt, data) => this._onLevelSwitched(evt, data));
50379
+ this._hls.on(Events.ERROR, (evt, data) => this._onHLSJSError(evt, data));
50338
50380
  this._hls.on(Events.AUDIO_TRACKS_UPDATED, (evt, data) => this._onAudioTracksUpdated(evt, data));
50339
50381
  this._hls.on(Events.AUDIO_TRACK_SWITCHED, (evt, data) => this._onAudioTrackSwitched(evt, data));
50382
+ this._hls.on(Events.CUES_PARSED, (evt, data) => {
50383
+ data.cues?.forEach((cue) => {
50384
+ this.cues.push({
50385
+ id: cue.id,
50386
+ start: cue.startTime,
50387
+ end: cue.endTime,
50388
+ text: cue.text,
50389
+ });
50390
+ });
50391
+ });
50340
50392
  this.bindCustomListeners();
50341
50393
  }
50342
50394
  bindCustomListeners() {
@@ -50355,13 +50407,6 @@ class HlsPlayback extends BasePlayback {
50355
50407
  requestedEventName && this._hls.off(requestedEventName, item.callback);
50356
50408
  });
50357
50409
  }
50358
- _onFragmentParsingMetadata(evt, data) {
50359
- // @ts-ignore
50360
- this.trigger(Events$1.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA, {
50361
- evt,
50362
- data,
50363
- });
50364
- }
50365
50410
  render() {
50366
50411
  this._ready();
50367
50412
  return super.render();
@@ -50443,6 +50488,7 @@ class HlsPlayback extends BasePlayback {
50443
50488
  this.dvrEnabled && this._updateDvr(time < this.getDuration() - 3);
50444
50489
  time += this._startTime;
50445
50490
  this.el.currentTime = time;
50491
+ this.triggerCues();
50446
50492
  }
50447
50493
  seekToLivePoint() {
50448
50494
  this.seek(this.getDuration());
@@ -50491,20 +50537,20 @@ class HlsPlayback extends BasePlayback {
50491
50537
  if (this._recoverAttemptsRemaining > 0) {
50492
50538
  this._recoverAttemptsRemaining -= 1;
50493
50539
  switch (data.type) {
50494
- case Hls.ErrorTypes.NETWORK_ERROR:
50540
+ case ErrorTypes.NETWORK_ERROR:
50495
50541
  switch (data.details) {
50496
50542
  // The following network errors cannot be recovered with HLS.startLoad()
50497
50543
  // For more details, see https://github.com/video-dev/hls.js/blob/master/doc/design.md#error-detection-and-handling
50498
50544
  // For "level load" fatal errors, see https://github.com/video-dev/hls.js/issues/1138
50499
50545
  // TODO test handling of these errors
50500
- case Hls.ErrorDetails.MANIFEST_LOAD_ERROR:
50501
- case Hls.ErrorDetails.MANIFEST_LOAD_TIMEOUT:
50502
- case Hls.ErrorDetails.MANIFEST_PARSING_ERROR:
50546
+ case ErrorDetails.MANIFEST_LOAD_ERROR:
50547
+ case ErrorDetails.MANIFEST_LOAD_TIMEOUT:
50548
+ case ErrorDetails.MANIFEST_PARSING_ERROR:
50503
50549
  // TODO sort out the errors below, perhaps some of them are recoverable
50504
- case Hls.ErrorDetails.LEVEL_LOAD_ERROR:
50505
- case Hls.ErrorDetails.LEVEL_LOAD_TIMEOUT:
50506
- case Hls.ErrorDetails.FRAG_LOAD_ERROR:
50507
- case Hls.ErrorDetails.FRAG_LOAD_TIMEOUT:
50550
+ case ErrorDetails.LEVEL_LOAD_ERROR:
50551
+ case ErrorDetails.LEVEL_LOAD_TIMEOUT:
50552
+ case ErrorDetails.FRAG_LOAD_ERROR:
50553
+ case ErrorDetails.FRAG_LOAD_TIMEOUT:
50508
50554
  Log.error('hlsjs: unrecoverable network fatal error.', {
50509
50555
  evt,
50510
50556
  data,
@@ -50521,11 +50567,11 @@ class HlsPlayback extends BasePlayback {
50521
50567
  details: data.details,
50522
50568
  });
50523
50569
  error.level = PlayerError.Levels.WARN;
50524
- this._hls?.startLoad();
50570
+ this.reload();
50525
50571
  break;
50526
50572
  }
50527
50573
  break;
50528
- case Hls.ErrorTypes.MEDIA_ERROR:
50574
+ case ErrorTypes.MEDIA_ERROR:
50529
50575
  Log.warn('hlsjs: trying to recover from media error.', {
50530
50576
  evt,
50531
50577
  data,
@@ -50566,9 +50612,14 @@ class HlsPlayback extends BasePlayback {
50566
50612
  });
50567
50613
  }
50568
50614
  }
50615
+ reload() {
50616
+ this.cues = [];
50617
+ this.currentCueId = null;
50618
+ this._hls?.startLoad(-1);
50619
+ }
50569
50620
  _keyIsDenied(data) {
50570
- return (data.type === Hls.ErrorTypes.NETWORK_ERROR &&
50571
- data.details === Hls.ErrorDetails.KEY_LOAD_ERROR &&
50621
+ return (data.type === ErrorTypes.NETWORK_ERROR &&
50622
+ data.details === ErrorDetails.KEY_LOAD_ERROR &&
50572
50623
  data.response &&
50573
50624
  data.response.code &&
50574
50625
  data.response.code >= 400);
@@ -50586,6 +50637,7 @@ class HlsPlayback extends BasePlayback {
50586
50637
  }
50587
50638
  this._lastTimeUpdate = update;
50588
50639
  this.trigger(Events$1.PLAYBACK_TIMEUPDATE, update, this.name);
50640
+ this.triggerCues();
50589
50641
  }
50590
50642
  _onDurationChange() {
50591
50643
  const duration = this.getDuration();
@@ -50624,6 +50676,20 @@ class HlsPlayback extends BasePlayback {
50624
50676
  };
50625
50677
  this.trigger(Events$1.PLAYBACK_PROGRESS, progress, buffered);
50626
50678
  }
50679
+ triggerCues() {
50680
+ const currentTime = this.getCurrentTime();
50681
+ // const cues = Object.values(this.cues)
50682
+ // TODO build a search tree
50683
+ const cue = this.cues.find((cue) => currentTime >= cue.start && currentTime <= cue.end);
50684
+ if (cue) {
50685
+ this.currentCueId = cue.id;
50686
+ this.oncueenter?.(cue);
50687
+ }
50688
+ else if (this.currentCueId) {
50689
+ this.oncueexit?.({ id: this.currentCueId });
50690
+ this.currentCueId = null;
50691
+ }
50692
+ }
50627
50693
  load(url) {
50628
50694
  this._stopTimeUpdateTimer();
50629
50695
  this.options.src = url;
@@ -50815,26 +50881,6 @@ class HlsPlayback extends BasePlayback {
50815
50881
  durationChanged && this._onDurationChange();
50816
50882
  startTimeChanged && this._onProgress();
50817
50883
  }
50818
- _onFragmentChanged(evt, data) {
50819
- this._currentFragment = data.frag;
50820
- // @ts-ignore
50821
- this.trigger(Events$1.Custom.PLAYBACK_FRAGMENT_CHANGED, data);
50822
- }
50823
- _onFragmentLoaded(evt, data) {
50824
- this.trigger(Events$1.PLAYBACK_FRAGMENT_LOADED, data);
50825
- }
50826
- // _onSubtitleLoaded() {
50827
- // trace(`${T} _onSubtitleLoaded`)
50828
- // // This event may be triggered multiple times
50829
- // // Setup CC only once (disable CC by default)
50830
- // if (!this._ccIsSetup) {
50831
- // this.trigger(Events.PLAYBACK_SUBTITLE_AVAILABLE)
50832
- // const trackId =
50833
- // this._playbackType === Playback.LIVE ? -1 : this.closedCaptionsTrackId
50834
- // this.closedCaptionsTrackId = trackId
50835
- // this._ccIsSetup = true
50836
- // }
50837
- // }
50838
50884
  _onLevelSwitch(evt, data) {
50839
50885
  if (!this.levels.length) {
50840
50886
  this._fillLevels();
@@ -50906,6 +50952,26 @@ class HlsPlayback extends BasePlayback {
50906
50952
  const track = this._hls.audioTracks[data.id];
50907
50953
  this.trigger(Events$1.PLAYBACK_AUDIO_CHANGED, toClapprTrack(track));
50908
50954
  }
50955
+ setTextTrack(id) {
50956
+ this._hls.subtitleTrack = id;
50957
+ }
50958
+ /**
50959
+ * @override
50960
+ */
50961
+ get closedCaptionsTracks() {
50962
+ return this.getTextTracks();
50963
+ }
50964
+ getTextTracks() {
50965
+ return this._hls?.subtitleTracks.map((t) => ({
50966
+ id: t.id,
50967
+ name: t.name,
50968
+ track: {
50969
+ id: t.id,
50970
+ label: t.name,
50971
+ language: t.lang,
50972
+ },
50973
+ })) || [];
50974
+ }
50909
50975
  }
50910
50976
  HlsPlayback.canPlay = function (resource, mimeType) {
50911
50977
  if (!isHlsSource(resource, mimeType)) {
@@ -51507,7 +51573,7 @@ class Player {
51507
51573
  }
51508
51574
  }
51509
51575
 
51510
- var version$1 = "2.28.28";
51576
+ var version$1 = "2.28.29";
51511
51577
 
51512
51578
  var packages = {
51513
51579
  "node_modules/@clappr/core": {
@@ -60058,6 +60124,7 @@ class ClosedCaptions extends UICorePlugin {
60058
60124
  bindEvents() {
60059
60125
  this.listenTo(this.core, Events$1.CORE_READY, this.onCoreReady);
60060
60126
  this.listenTo(this.core, Events$1.CORE_ACTIVE_CONTAINER_CHANGED, this.onContainerChanged);
60127
+ this.listenTo(this.core, Events$1.PLAYBACK_READY, this.onPlaybackReady);
60061
60128
  }
60062
60129
  onCoreReady() {
60063
60130
  const mediaControl = this.core.getPlugin('media_control');
@@ -60071,18 +60138,15 @@ class ClosedCaptions extends UICorePlugin {
60071
60138
  this.hideMenu();
60072
60139
  }
60073
60140
  });
60141
+ this.onPlaybackReady();
60074
60142
  }
60075
60143
  onContainerChanged() {
60144
+ this.tracks = [];
60076
60145
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_FULLSCREEN, this.onContainerResize);
60077
60146
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_RESIZE, this.onContainerResize);
60078
60147
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_DESTROYED, () => {
60079
60148
  this.clickaway(null);
60080
60149
  });
60081
- // this.listenTo(
60082
- // this.core.activeContainer,
60083
- // 'container:advertisement:start',
60084
- // this.onStartAd,
60085
- // )
60086
60150
  this.listenTo(this.core.activePlayback, Events$1.PLAYBACK_SUBTITLE_AVAILABLE, this.onSubtitleAvailable);
60087
60151
  this.listenTo(this.core.activePlayback, Events$1.PLAYBACK_SUBTITLE_CHANGED, this.onSubtitleChanged);
60088
60152
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_CLICK, () => {
@@ -60104,27 +60168,33 @@ class ClosedCaptions extends UICorePlugin {
60104
60168
  });
60105
60169
  this.isPreselectedApplied = false;
60106
60170
  }
60171
+ onPlaybackReady() {
60172
+ trace(`${T$3} onPlaybackReady`);
60173
+ this.core.activePlayback.oncueenter = (e) => {
60174
+ this.setSubtitleText(e.text);
60175
+ };
60176
+ this.core.activePlayback.oncueexit = () => {
60177
+ this.clearSubtitleText();
60178
+ };
60179
+ }
60107
60180
  onSubtitleAvailable() {
60108
- trace(`${T$3} onSubtitleAvailable`, {
60109
- tracks: this.core.activePlayback.closedCaptionsTracks.length,
60110
- });
60111
60181
  this.applyTracks();
60112
60182
  this.mount();
60113
60183
  }
60114
60184
  onSubtitleChanged({ id: changedId }) {
60115
60185
  // ignoring the subtitle selected by the playback engine or user agent
60116
- const id = this.track?.id ?? -1;
60117
- trace(`${T$3} onSubtitleChanged`, {
60118
- changedId,
60119
- id,
60120
- });
60186
+ const id = this.currentTrack?.id ?? -1;
60121
60187
  if (id === -1) {
60122
60188
  this.clearSubtitleText();
60123
60189
  }
60124
60190
  this.activateTrack(id);
60125
60191
  }
60126
60192
  activateTrack(id) {
60127
- for (const track of this.tracks) {
60193
+ if (['dash', 'hls'].includes(this.core.activePlayback?.name)) {
60194
+ this.core.activePlayback.setTextTrack(id);
60195
+ return;
60196
+ }
60197
+ for (const track of this.currentTracks) {
60128
60198
  if (track.id === id) {
60129
60199
  if (this.useNativeSubtitles) {
60130
60200
  track.track.mode = 'showing';
@@ -60149,14 +60219,15 @@ class ClosedCaptions extends UICorePlugin {
60149
60219
  };
60150
60220
  }
60151
60221
  else {
60152
- track.track.oncuechange = null;
60222
+ track.track.oncuechange = () => { };
60153
60223
  track.track.mode = 'disabled';
60154
60224
  }
60155
60225
  }
60156
60226
  }
60157
60227
  applyTracks() {
60158
60228
  try {
60159
- this.tracks = this.core.activePlayback.closedCaptionsTracks;
60229
+ // TODO ensure to apply only once
60230
+ this.currentTracks = this.core.activePlayback.closedCaptionsTracks;
60160
60231
  this.applyPreselectedSubtitles();
60161
60232
  this.render();
60162
60233
  }
@@ -60164,29 +60235,11 @@ class ClosedCaptions extends UICorePlugin {
60164
60235
  reportError(error);
60165
60236
  }
60166
60237
  }
60167
- // private onStartAd() {
60168
- // if (this.active && this.core.activeContainer) {
60169
- // this.hide()
60170
- // this.listenTo(
60171
- // this.core.activeContainer,
60172
- // 'container:advertisement:finish',
60173
- // this.onFinishAd,
60174
- // )
60175
- // }
60176
- // }
60177
- // private onFinishAd() {
60178
- // this.show()
60179
- // this.stopListening(
60180
- // this.core.activeContainer,
60181
- // 'container:advertisement:finish',
60182
- // this.onFinishAd,
60183
- // )
60184
- // }
60185
60238
  onContainerResize() {
60186
60239
  const shouldShow = this.core.activeContainer &&
60187
60240
  isFullscreen(this.core.activeContainer.el) &&
60188
- this.track &&
60189
- this.track.track.mode &&
60241
+ this.currentTrack &&
60242
+ this.currentTrack.track.mode &&
60190
60243
  Browser.isiOS &&
60191
60244
  this.active;
60192
60245
  if (shouldShow) {
@@ -60210,10 +60263,8 @@ class ClosedCaptions extends UICorePlugin {
60210
60263
  this.$el.find('#gplayer-cc-menu').hide();
60211
60264
  this.$el.find('#gplayer-cc-button').attr('aria-expanded', 'false');
60212
60265
  this.$line.hide();
60213
- if (this.tracks) {
60214
- for (const t of this.tracks) {
60215
- t.track.mode = 'hidden';
60216
- }
60266
+ for (const track of this.currentTracks) {
60267
+ track.track.mode = 'hidden';
60217
60268
  }
60218
60269
  }
60219
60270
  /**
@@ -60224,18 +60275,19 @@ class ClosedCaptions extends UICorePlugin {
60224
60275
  this.renderIcon();
60225
60276
  if (this.core.activeContainer &&
60226
60277
  isFullscreen(this.core.activeContainer.el) &&
60227
- this.track &&
60228
- this.track.track.mode &&
60278
+ this.currentTrack &&
60279
+ // this.currentTrack.track.mode &&
60229
60280
  (Browser.isiOS || this.useNativeSubtitles)) {
60230
60281
  this.$line.hide();
60231
- this.track.track.mode = 'showing';
60282
+ this.currentTrack.track.mode = 'showing';
60232
60283
  }
60233
60284
  else {
60234
60285
  this.$line.show();
60235
60286
  }
60236
60287
  }
60237
60288
  shouldRender() {
60238
- return this.tracks?.length > 0;
60289
+ // this might not have been fully initialized yet since `render` is called from the parent class constructor
60290
+ return this.currentTracks?.length > 0;
60239
60291
  }
60240
60292
  resizeFont() {
60241
60293
  if (!this.$line) {
@@ -60248,13 +60300,16 @@ class ClosedCaptions extends UICorePlugin {
60248
60300
  * @internal
60249
60301
  */
60250
60302
  render() {
60303
+ if (!this.shouldRender()) {
60304
+ return this;
60305
+ }
60251
60306
  if (!this.core.activeContainer) {
60252
60307
  return this;
60253
60308
  }
60254
60309
  this.$el.html(ClosedCaptions.templateControl({
60255
- tracks: this.tracks ?? [],
60310
+ tracks: this.currentTracks,
60256
60311
  i18n: this.core.i18n,
60257
- current: this.track?.id ?? -1,
60312
+ current: this.currentTrack?.id ?? -1,
60258
60313
  }));
60259
60314
  this.$el.find('#gplayer-cc-menu').hide();
60260
60315
  this.open = false;
@@ -60268,11 +60323,11 @@ class ClosedCaptions extends UICorePlugin {
60268
60323
  return this;
60269
60324
  }
60270
60325
  findById(id) {
60271
- return this.tracks.find((track) => track.id === id) ?? null;
60326
+ return this.currentTracks.find((track) => track.id === id) || null;
60272
60327
  }
60273
60328
  selectItem(item) {
60274
60329
  this.clearSubtitleText();
60275
- this.track = item;
60330
+ this.currentTrack = item;
60276
60331
  const trackId = item?.id ?? -1;
60277
60332
  this.core.activePlayback.closedCaptionsTrackId = trackId;
60278
60333
  this.updateSelection();
@@ -60329,7 +60384,7 @@ class ClosedCaptions extends UICorePlugin {
60329
60384
  return this.$el.find('#gplayer-cc-menu li'); // TODO fix semantically
60330
60385
  }
60331
60386
  selectSubtitles() {
60332
- const trackId = this.track ? this.track.id : -1;
60387
+ const trackId = this.currentTrack?.id ?? -1;
60333
60388
  // TODO find out if this is needed
60334
60389
  this.core.activePlayback.closedCaptionsTrackId = trackId;
60335
60390
  // this.core.activePlayback.closedCaptionsTrackId = -1
@@ -60355,7 +60410,7 @@ class ClosedCaptions extends UICorePlugin {
60355
60410
  this.setSubtitleText('');
60356
60411
  }
60357
60412
  updateSelection() {
60358
- if (!this.track) {
60413
+ if (!this.currentTrack) {
60359
60414
  this.hide();
60360
60415
  }
60361
60416
  else {
@@ -60370,7 +60425,7 @@ class ClosedCaptions extends UICorePlugin {
60370
60425
  .find('a')
60371
60426
  .removeClass('gcore-skin-active')
60372
60427
  .attr('aria-checked', 'false');
60373
- const currentLevelElement = this.itemElement(this.track ? this.track.id : -1);
60428
+ const currentLevelElement = this.itemElement(this.currentTrack?.id ?? -1);
60374
60429
  currentLevelElement
60375
60430
  .addClass('current')
60376
60431
  .find('a')
@@ -60395,15 +60450,28 @@ class ClosedCaptions extends UICorePlugin {
60395
60450
  }
60396
60451
  }
60397
60452
  get useNativeSubtitles() {
60398
- if (this.core.activePlayback?.name === 'dash') {
60399
- return true;
60400
- }
60401
60453
  const mode = this.core.options.cc?.mode ??
60402
60454
  this.core.options.subtitles?.mode ??
60403
60455
  'custom';
60404
60456
  // TODO or Safari? or iOS?
60405
60457
  return mode === 'native';
60406
60458
  }
60459
+ get currentTracks() {
60460
+ return this.tracks;
60461
+ }
60462
+ get currentTrack() {
60463
+ return this.track;
60464
+ }
60465
+ set currentTrack(track) {
60466
+ this.track = track;
60467
+ }
60468
+ set currentTracks(tracks) {
60469
+ this.tracks = tracks.map(track => ({
60470
+ id: track.id,
60471
+ name: !track.name || track.name === "null" ? track.track.language : track.name,
60472
+ track: track.track,
60473
+ }));
60474
+ }
60407
60475
  clickaway = mediaControlClickaway(() => this.hideMenu());
60408
60476
  }
60409
60477
 
@@ -1 +1 @@
1
- {"version":3,"file":"BasePlayback.d.ts","sourceRoot":"","sources":["../../src/playback/BasePlayback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,UAAU,EAAe,MAAM,cAAc,CAAA;AAI5E;;;GAGG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,IAAI,YAAY,YAEf;IAED,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;IA0BlD;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM;IAInB,UAAU;CAIpB"}
1
+ {"version":3,"file":"BasePlayback.d.ts","sourceRoot":"","sources":["../../src/playback/BasePlayback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,UAAU,EAAe,MAAM,cAAc,CAAA;AAK5E;;;GAGG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,IAAI,YAAY,YAEf;IAED,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;IA0BlD;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM;IAInB,UAAU;CAIpB"}
@@ -1,6 +1,6 @@
1
1
  import { Playback } from '@clappr/core';
2
- import { IManifestInfo, MediaPlayerClass, Representation } from 'dashjs';
3
- import { QualityLevel, TimePosition, TimeValue } from '../../playback.types.js';
2
+ import { MediaPlayerClass, IManifestInfo } from 'dashjs';
3
+ import { QualityLevel, TimePosition, TimeValue, VTTCueInfo } from '../../playback.types.js';
4
4
  import { BasePlayback } from '../BasePlayback.js';
5
5
  import { AudioTrack } from '@clappr/core/types/base/playback/playback.js';
6
6
  type PlaybackType = typeof Playback.VOD | typeof Playback.LIVE | typeof Playback.AOD | typeof Playback.NO_OP;
@@ -28,6 +28,10 @@ export default class DashPlayback extends BasePlayback {
28
28
  startChangeQuality: boolean;
29
29
  manifestInfo: IManifestInfo | null;
30
30
  _timeUpdateTimer: ReturnType<typeof setInterval> | null;
31
+ oncueenter: ((e: VTTCueInfo) => void) | null;
32
+ oncueexit: ((e: {
33
+ id: string;
34
+ }) => void) | null;
31
35
  get name(): string;
32
36
  get levels(): QualityLevel[];
33
37
  get currentLevel(): number;
@@ -66,7 +70,7 @@ export default class DashPlayback extends BasePlayback {
66
70
  private destroyInstance;
67
71
  destroy(): void;
68
72
  _updatePlaybackType(): void;
69
- _fillLevels(levels: Representation[]): void;
73
+ private _fillLevels;
70
74
  private onLevelSwitch;
71
75
  private onLevelSwitchEnd;
72
76
  getPlaybackType(): string;
@@ -82,6 +86,21 @@ export default class DashPlayback extends BasePlayback {
82
86
  * @override
83
87
  */
84
88
  _handleTextTrackChange(): void;
89
+ setTextTrack(id: number): void;
90
+ /**
91
+ * @override
92
+ */
93
+ get closedCaptionsTracks(): {
94
+ id: number;
95
+ name: string;
96
+ track: {
97
+ id: number;
98
+ label: string;
99
+ language: string | null;
100
+ mode: string;
101
+ };
102
+ }[];
103
+ private getTextTracks;
85
104
  }
86
105
  export {};
87
106
  //# sourceMappingURL=DashPlayback.d.ts.map