@gcorevideo/player 2.20.22 → 2.21.3

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 (89) hide show
  1. package/assets/audio-selector/style.scss +48 -82
  2. package/assets/audio-selector/track-selector.ejs +3 -3
  3. package/assets/bottom-gear/bottomgear.ejs +10 -12
  4. package/assets/bottom-gear/gear-sub-menu.scss +0 -15
  5. package/assets/bottom-gear/gear.scss +3 -32
  6. package/assets/media-control/media-control.ejs +5 -25
  7. package/assets/media-control/media-control.scss +114 -34
  8. package/assets/media-control/width370.scss +35 -109
  9. package/assets/picture-in-picture/button.ejs +1 -1
  10. package/assets/picture-in-picture/button.scss +5 -4
  11. package/assets/subtitles/combobox.ejs +7 -9
  12. package/assets/subtitles/style.scss +8 -15
  13. package/dist/core.js +151 -23
  14. package/dist/index.css +897 -1000
  15. package/dist/index.js +416 -438
  16. package/dist/player.d.ts +19 -16
  17. package/dist/plugins/index.css +1454 -1557
  18. package/dist/plugins/index.js +826 -23550
  19. package/docs/api/player.audioselector.md +4 -59
  20. package/docs/api/player.md +1 -1
  21. package/docs/api/player.mediacontrol.getelement.md +5 -0
  22. package/docs/api/player.mediacontrol.md +14 -0
  23. package/docs/api/{player.audioselector.updatecurrenttrack.md → player.mediacontrol.putelement.md} +7 -7
  24. package/docs/api/player.mediacontrolelement.md +1 -1
  25. package/docs/api/{player.audioselector.starttrackswitch.md → player.pictureinpicture.attributes.md} +5 -7
  26. package/docs/api/player.pictureinpicture.md +45 -0
  27. package/lib/playback/BasePlayback.d.ts +1 -1
  28. package/lib/playback/BasePlayback.d.ts.map +1 -1
  29. package/lib/playback/BasePlayback.js +3 -1
  30. package/lib/playback/HTML5Video.d.ts +4 -0
  31. package/lib/playback/HTML5Video.d.ts.map +1 -1
  32. package/lib/playback/HTML5Video.js +53 -4
  33. package/lib/playback/dash-playback/DashPlayback.d.ts +5 -0
  34. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  35. package/lib/playback/dash-playback/DashPlayback.js +48 -4
  36. package/lib/playback/hls-playback/HlsPlayback.d.ts +31 -25
  37. package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
  38. package/lib/playback/hls-playback/HlsPlayback.js +47 -14
  39. package/lib/playback.types.d.ts +5 -0
  40. package/lib/playback.types.d.ts.map +1 -1
  41. package/lib/plugins/audio-selector/AudioSelector.d.ts +12 -11
  42. package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
  43. package/lib/plugins/audio-selector/AudioSelector.js +65 -185
  44. package/lib/plugins/bottom-gear/BottomGear.d.ts +2 -2
  45. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  46. package/lib/plugins/bottom-gear/BottomGear.js +12 -10
  47. package/lib/plugins/level-selector/LevelSelector.js +1 -1
  48. package/lib/plugins/media-control/MediaControl.d.ts +3 -4
  49. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  50. package/lib/plugins/media-control/MediaControl.js +23 -13
  51. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +3 -0
  52. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  53. package/lib/plugins/picture-in-picture/PictureInPicture.js +6 -1
  54. package/lib/plugins/playback-rate/PlaybackRate.d.ts +1 -0
  55. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  56. package/lib/plugins/playback-rate/PlaybackRate.js +1 -0
  57. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  58. package/lib/plugins/source-controller/SourceController.js +0 -1
  59. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +0 -2
  60. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  61. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +1 -18
  62. package/lib/plugins/subtitles/Subtitles.d.ts +21 -19
  63. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -1
  64. package/lib/plugins/subtitles/Subtitles.js +121 -151
  65. package/lib/testUtils.d.ts.map +1 -1
  66. package/lib/testUtils.js +2 -0
  67. package/package.json +1 -1
  68. package/src/playback/BasePlayback.ts +4 -1
  69. package/src/playback/HTML5Video.ts +57 -4
  70. package/src/playback/dash-playback/DashPlayback.ts +64 -6
  71. package/src/playback/hls-playback/HlsPlayback.ts +82 -40
  72. package/src/playback.types.ts +6 -0
  73. package/src/plugins/audio-selector/AudioSelector.ts +84 -278
  74. package/src/plugins/bottom-gear/BottomGear.ts +14 -11
  75. package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +1 -3
  76. package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +14 -37
  77. package/src/plugins/level-selector/LevelSelector.ts +1 -1
  78. package/src/plugins/media-control/MediaControl.ts +54 -32
  79. package/src/plugins/picture-in-picture/PictureInPicture.ts +7 -1
  80. package/src/plugins/playback-rate/PlaybackRate.ts +1 -0
  81. package/src/plugins/source-controller/SourceController.ts +0 -1
  82. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +1 -20
  83. package/src/plugins/subtitles/Subtitles.ts +144 -179
  84. package/src/testUtils.ts +2 -0
  85. package/src/typings/globals.d.ts +19 -0
  86. package/temp/player.api.json +102 -143
  87. package/tsconfig.tsbuildinfo +1 -1
  88. package/assets/media-control/plugins.scss +0 -94
  89. package/docs/api/player.audioselector.highlightcurrenttrack.md +0 -18
@@ -1,11 +1,9 @@
1
1
  .media-control-skin-1[data-media-control-skin-1].w370 {
2
2
  .media-control-subtitles {
3
- .subtitles[data-subtitles] {
4
- width: 28px;
3
+ width: 28px;
5
4
 
6
- svg {
7
- height: 17px;
8
- }
5
+ svg {
6
+ height: 17px;
9
7
  }
10
8
  }
11
9
 
@@ -18,29 +16,6 @@
18
16
  max-height: 300px;
19
17
  transform: none;
20
18
 
21
- .share-container-main {
22
- // .share-container-header--linktext,
23
- // .share-container-header--socialtext,
24
- // .share-container-header--embedtext,
25
- // .share-container-header--embed {
26
- // display: none;
27
- // }
28
-
29
- //.share-container-header--socialicon {
30
- // margin-top: -84px;
31
- //}
32
- //
33
- //.share-container-header--link {
34
- // width: 100%;
35
- // border-left: none;
36
- // border-right: none;
37
- // margin-top: 52px;
38
- // height: 32px;
39
- // font-size: 12px;
40
- // padding: 10px;
41
- //}
42
- }
43
-
44
19
  .share-container-header {
45
20
  border: none;
46
21
 
@@ -54,39 +29,42 @@
54
29
  .media-control-quality,
55
30
  .media-control-audio-tracks {
56
31
  display: block;
32
+ }
57
33
 
58
- .level_selector[data-level-selector],
59
- .audio_selector[data-track-selector] {
60
- margin-top: 3px;
61
- margin-right: 10px;
34
+ .level-selector[data-level-selector],
35
+ .media-control-audio-tracks[data-track-selector] {
36
+ margin-top: 3px;
37
+ margin-right: 10px;
62
38
 
63
- ul {
64
- bottom: 30px;
65
- width: 50px;
39
+ ul {
40
+ bottom: 30px;
41
+ width: 50px;
66
42
 
67
- li {
68
- height: 23px;
69
- font-size: 14px;
43
+ li {
44
+ height: 23px;
45
+ font-size: 14px;
70
46
 
71
- a {
72
- height: 23px;
73
- padding: 2px 5px;
74
- }
47
+ a {
48
+ height: 23px;
49
+ padding: 2px 5px;
75
50
  }
76
51
  }
52
+ }
77
53
 
78
- button[data-level-selector-button],
79
- button[data-track-selector-button] {
80
- .quality-text, .audio-text {
81
- font-size: 13px;
82
- }
54
+ button[data-level-selector-button],
55
+ button[data-track-selector-button] {
83
56
 
84
- span.quality-arrow, span.audio-arrow {
85
- width: 7px;
86
- height: 5px;
87
- margin-left: 4px;
88
- margin-top: 11px;
89
- }
57
+ .quality-text,
58
+ .audio-text {
59
+ font-size: 13px;
60
+ }
61
+
62
+ span.quality-arrow,
63
+ span.audio-arrow {
64
+ width: 7px;
65
+ height: 5px;
66
+ margin-left: 4px;
67
+ margin-top: 11px;
90
68
  }
91
69
  }
92
70
  }
@@ -104,54 +82,12 @@
104
82
  margin: 0;
105
83
  }
106
84
  }
107
-
108
- // ul {
109
- // width: 150px;
110
- // bottom: 32px;
111
- // padding: 0;
112
-
113
- // li {
114
- // .multicamera-item {
115
- // .multicamera-poster {
116
- // width: 40px;
117
- // height: 30px;
118
- // img {
119
- // width: 40px;
120
- // height: 30px;
121
- // }
122
- // }
123
- // .multicamera-text {
124
- // width: 70px;
125
- // .multicamera-title {
126
- // width: 70px;
127
- // height: 15px;
128
- // font-size: 12px;
129
- // }
130
- // }
131
- // }
132
- // }
133
- // &::after {
134
- // display: none;
135
- // }
136
- // }
137
-
138
85
  }
139
86
  }
140
87
 
141
88
  .media-control-layer[data-controls] {
142
- height: 32px;
143
-
144
- .media-control-bottomgear {
145
- .button-gear {
146
- height: 33px;
147
- margin-right: 10px;
148
- padding-right: 0;
149
-
150
- svg {
151
- height: 17px;
152
- }
153
- }
154
- }
89
+ padding-left: 10px;
90
+ padding-right: 12px;
155
91
 
156
92
  .media-control-indicator {
157
93
  line-height: 32px;
@@ -201,18 +137,7 @@
201
137
  button.media-control-button {
202
138
  height: 32px;
203
139
 
204
- &[data-playpause] {
205
- margin-left: 10px;
206
- margin-right: 10px;
207
- }
208
-
209
- &[data-playstop] {
210
- margin-left: 10px;
211
- margin-right: 10px;
212
- }
213
-
214
140
  &[data-fullscreen] {
215
- margin-right: 12px;
216
141
  height: 33px;
217
142
  }
218
143
 
@@ -222,6 +147,7 @@
222
147
  }
223
148
 
224
149
  .media-clip-container {
150
+
225
151
  .media-clip-text,
226
152
  .media-clip-point {
227
153
  line-height: 33px;
@@ -260,4 +186,4 @@
260
186
  }
261
187
  }
262
188
  }
263
- }
189
+ }
@@ -1,3 +1,3 @@
1
1
  <button class="gplayer-lite-btn gcore-skin-button-color">
2
- <span><%= pipIcon %></span>
2
+ <%= pipIcon %>
3
3
  </button>
@@ -1,11 +1,12 @@
1
1
  .media-control-pip {
2
+ order: 95;
3
+ display: flex;
4
+
2
5
  button {
3
- float: right;
4
- height: 40px;
5
- margin-right: 20px;
6
+ height: 20px;
6
7
 
7
8
  svg {
8
9
  height: 20px;
9
10
  }
10
11
  }
11
- }
12
+ }
@@ -3,14 +3,12 @@
3
3
  </button>
4
4
 
5
5
  <ul class='gcore-skin-bg-color'>
6
- <li><a href="#" class='gcore-skin-text-color' data-subtitles-select="off">off</a></li>
7
- <% for (const track of tracks) { %>
8
- <% if (track.kind === 'subtitles' || track.kind === 'captions') { %>
9
- <li>
10
- <a href="#" class='gcore-skin-text-color' data-subtitles-select="<%= track.language %>">
11
- <%= track.label %>
12
- </a>
13
- </li>
14
- <% } %>
6
+ <% for (const t of tracks) { %>
7
+ <li>
8
+ <a href="#" class='gcore-skin-text-color' data-subtitles-select="<%= t.id %>">
9
+ <%= t.name %>
10
+ </a>
11
+ </li>
15
12
  <% } %>
13
+ <li><a href="#" class='gcore-skin-text-color' data-subtitles-select="-1">Off</a></li>
16
14
  </ul>
@@ -1,19 +1,18 @@
1
- *, :focus, :visited {
1
+ *,
2
+ :focus,
3
+ :visited {
2
4
  outline: none !important;
3
5
  }
4
6
 
5
- .subtitles[data-subtitles] {
6
- float: right;
7
+ .media-control-subtitles[data-subtitles] {
7
8
  position: relative;
8
- width: 50px;
9
+ order: 85;
9
10
 
10
11
  button {
11
12
  background-color: transparent;
12
13
  color: #fff;
13
- font-family: Roboto, "Open Sans", Arial, sans-serif;
14
14
  -webkit-font-smoothing: antialiased;
15
15
  border: none;
16
- font-size: 14px;
17
16
  cursor: pointer;
18
17
 
19
18
  .subtitle-text {
@@ -31,7 +30,7 @@
31
30
  }
32
31
  }
33
32
 
34
- & > ul {
33
+ ul {
35
34
  width: 80px;
36
35
  list-style-type: none;
37
36
  position: absolute;
@@ -39,16 +38,10 @@
39
38
  border: 1px solid black;
40
39
  display: none;
41
40
  background-color: #e6e6e6;
41
+ padding: 8px 0;
42
42
  }
43
43
 
44
44
  li {
45
- font-size: 10px;
46
-
47
- &[data-title] {
48
- background-color: #c3c2c2;
49
- padding: 5px;
50
- }
51
-
52
45
  a {
53
46
  color: #444;
54
47
  padding: 2px 10px;
@@ -96,4 +89,4 @@
96
89
  .ios-fullscreen::cue {
97
90
  visibility: visible !important;
98
91
  font-size: 1em !important;
99
- }
92
+ }
package/dist/core.js CHANGED
@@ -12540,9 +12540,11 @@ var PlaybackErrorCode;
12540
12540
  /**
12541
12541
  * This class adds common behaviors to all playback modules.
12542
12542
  * @internal
12543
- * TODO use custom HTML5Video playback with this layer applied
12544
12543
  */
12545
12544
  class BasePlayback extends HTML5Video$1 {
12545
+ get isHTML5Video() {
12546
+ return true;
12547
+ }
12546
12548
  createError(errorData, options) {
12547
12549
  const i18n = this.i18n ||
12548
12550
  // @ts-ignore
@@ -12586,13 +12588,13 @@ var PlaybackEvents;
12586
12588
  PlaybackEvents["PLAYBACK_RATE_CHANGED"] = "playback:rate-changed";
12587
12589
  })(PlaybackEvents || (PlaybackEvents = {}));
12588
12590
 
12589
- // Copyright 2014 Globo.com Player authors. All rights reserved.
12590
- // Use of this source code is governed by a BSD-style
12591
- // license that can be found in the LICENSE file.
12591
+ // This code is derived on works by Globo.com.
12592
+ // This code is distributed under the terms of the Apache License 2.0.
12593
+ // Original code's license can be found on
12594
+ // https://github.com/clappr/clappr/blob/8752995ea439321ac7ca3cd35e8c64de7a3c3d17/LICENSE
12592
12595
  const AUTO$1 = -1;
12593
12596
  const { now: now$2 } = Utils;
12594
12597
  const T$3 = 'playback.dash';
12595
- // @ts-expect-error
12596
12598
  class DashPlayback extends BasePlayback {
12597
12599
  _levels = null;
12598
12600
  _currentLevel = null;
@@ -12752,6 +12754,7 @@ class DashPlayback extends BasePlayback {
12752
12754
  const newLevel = this.getLevel(evt.newQuality);
12753
12755
  this.onLevelSwitch(newLevel);
12754
12756
  });
12757
+ this.checkAudioTracks();
12755
12758
  });
12756
12759
  this._dash.on(DASHJS.MediaPlayer.events.QUALITY_CHANGE_RENDERED, (evt) => {
12757
12760
  const currentLevel = this.getLevel(evt.newQuality);
@@ -12772,6 +12775,11 @@ class DashPlayback extends BasePlayback {
12772
12775
  this._dash.on(DASHJS.MediaPlayer.events.PLAYBACK_RATE_CHANGED, (e) => {
12773
12776
  this.trigger(PlaybackEvents.PLAYBACK_RATE_CHANGED, e.playbackRate);
12774
12777
  });
12778
+ this._dash.on(DASHJS.MediaPlayer.events.TRACK_CHANGE_RENDERED, (e) => {
12779
+ if (e.mediaType === 'audio') {
12780
+ this.trigger(Events$1.PLAYBACK_AUDIO_CHANGED, toClapprTrack$1(e.newMediaInfo));
12781
+ }
12782
+ });
12775
12783
  }
12776
12784
  render() {
12777
12785
  this._ready();
@@ -13039,6 +13047,36 @@ class DashPlayback extends BasePlayback {
13039
13047
  setPlaybackRate(rate) {
13040
13048
  this._dash?.setPlaybackRate(rate);
13041
13049
  }
13050
+ get audioTracks() {
13051
+ assert.ok(this._dash, 'DASH.js MediaPlayer is not initialized');
13052
+ const tracks = this._dash.getTracksFor('audio');
13053
+ trace(`${T$3} get audioTracks`, { tracks });
13054
+ return tracks.map(toClapprTrack$1);
13055
+ }
13056
+ // @ts-expect-error
13057
+ get currentAudioTrack() {
13058
+ trace(`${T$3} get currentAudioTrack`);
13059
+ assert.ok(this._dash, 'DASH.js MediaPlayer is not initialized');
13060
+ const t = this._dash.getCurrentTrackFor('audio');
13061
+ if (!t) {
13062
+ return null;
13063
+ }
13064
+ return toClapprTrack$1(t);
13065
+ }
13066
+ switchAudioTrack(id) {
13067
+ assert.ok(this._dash, 'DASH.js MediaPlayer is not initialized');
13068
+ const tracks = this._dash.getTracksFor('audio');
13069
+ const track = tracks.find((t) => t.id === id);
13070
+ assert.ok(track, 'Invalid audio track ID');
13071
+ this._dash.setCurrentTrack(track);
13072
+ }
13073
+ checkAudioTracks() {
13074
+ // @ts-ignore
13075
+ const tracks = this._dash.getTracksFor('audio');
13076
+ if (tracks.length) {
13077
+ this.trigger(Events$1.PLAYBACK_AUDIO_AVAILABLE, tracks.map(toClapprTrack$1));
13078
+ }
13079
+ }
13042
13080
  }
13043
13081
  DashPlayback.canPlay = function (resource, mimeType) {
13044
13082
  if (!isDashSource(resource, mimeType)) {
@@ -13050,6 +13088,14 @@ DashPlayback.canPlay = function (resource, mimeType) {
13050
13088
  const ctor = ms || mms || wms;
13051
13089
  return typeof ctor === 'function';
13052
13090
  };
13091
+ function toClapprTrack$1(t) {
13092
+ return {
13093
+ id: t.id,
13094
+ kind: t.roles && t.roles?.length > 0 ? t.roles[0] : 'main', // TODO
13095
+ label: t.labels.map((l) => l.text).join(' '), // TODO
13096
+ language: t.lang,
13097
+ };
13098
+ }
13053
13099
 
13054
13100
  function getDefaultExportFromCjs (x) {
13055
13101
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -41711,7 +41757,6 @@ const DEFAULT_RECOVER_ATTEMPTS = 16;
41711
41757
  Events$1.register('PLAYBACK_FRAGMENT_CHANGED');
41712
41758
  Events$1.register('PLAYBACK_FRAGMENT_PARSING_METADATA');
41713
41759
  const T$2 = 'playback.hls';
41714
- // @ts-expect-error
41715
41760
  class HlsPlayback extends BasePlayback {
41716
41761
  _ccIsSetup = false;
41717
41762
  _ccTracksUpdated = false;
@@ -41756,7 +41801,7 @@ class HlsPlayback extends BasePlayback {
41756
41801
  set currentLevel(id) {
41757
41802
  this._currentLevel = id;
41758
41803
  this.trigger(Events$1.PLAYBACK_LEVEL_SWITCH_START);
41759
- assert.ok(this._hls, 'Hls.js instance is not available');
41804
+ assert.ok(this._hls, 'HLS.js is not initialized');
41760
41805
  if (this.options.playback.hlsUseNextLevel) {
41761
41806
  this._hls.nextLevel = this._currentLevel;
41762
41807
  }
@@ -41765,11 +41810,11 @@ class HlsPlayback extends BasePlayback {
41765
41810
  }
41766
41811
  }
41767
41812
  get latency() {
41768
- assert.ok(this._hls, 'Hls.js instance is not available');
41813
+ assert.ok(this._hls, 'HLS.js is not initialized');
41769
41814
  return this._hls.latency;
41770
41815
  }
41771
41816
  get currentProgramDateTime() {
41772
- assert.ok(this._hls, 'Hls.js instance is not available');
41817
+ assert.ok(this._hls, 'HLS.js is not initialized');
41773
41818
  assert.ok(this._hls.playingDate, 'Hls.js playingDate is not defined');
41774
41819
  return this._hls.playingDate;
41775
41820
  }
@@ -41954,7 +41999,7 @@ class HlsPlayback extends BasePlayback {
41954
41999
  return;
41955
42000
  }
41956
42001
  this._hls.once(Hls.Events.MEDIA_ATTACHED, () => {
41957
- assert.ok(this._hls, 'Hls.js instance is not available');
42002
+ assert.ok(this._hls, 'HLS.js is not initialized');
41958
42003
  this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src);
41959
42004
  });
41960
42005
  const onPlaying = () => {
@@ -41979,13 +42024,15 @@ class HlsPlayback extends BasePlayback {
41979
42024
  // this._hls.on(HLSJS.Events.SUBTITLE_TRACK_LOADED, (evt, data) => this._onSubtitleLoaded(evt, data));
41980
42025
  this._hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, () => this._onSubtitleLoaded());
41981
42026
  this._hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, () => (this._ccTracksUpdated = true));
42027
+ this._hls.on(Events.AUDIO_TRACKS_UPDATED, (evt, data) => this._onAudioTracksUpdated(evt, data));
42028
+ this._hls.on(Events.AUDIO_TRACK_SWITCHED, (evt, data) => this._onAudioTrackSwitched(evt, data));
41982
42029
  this.bindCustomListeners();
41983
42030
  }
41984
42031
  bindCustomListeners() {
41985
42032
  this.customListeners.forEach((item) => {
41986
42033
  const requestedEventName = item.eventName;
41987
42034
  const typeOfListener = item.once ? 'once' : 'on';
41988
- assert.ok(this._hls, 'Hls.js instance is not available');
42035
+ assert.ok(this._hls, 'HLS.js is not initialized');
41989
42036
  requestedEventName &&
41990
42037
  this._hls[`${typeOfListener}`](requestedEventName, item.callback);
41991
42038
  });
@@ -41993,7 +42040,7 @@ class HlsPlayback extends BasePlayback {
41993
42040
  unbindCustomListeners() {
41994
42041
  this.customListeners.forEach((item) => {
41995
42042
  const requestedEventName = item.eventName;
41996
- assert.ok(this._hls, 'Hls.js instance is not available');
42043
+ assert.ok(this._hls, 'HLS.js is not initialized');
41997
42044
  requestedEventName && this._hls.off(requestedEventName, item.callback);
41998
42045
  });
41999
42046
  }
@@ -42017,7 +42064,7 @@ class HlsPlayback extends BasePlayback {
42017
42064
  this.trigger(Events$1.PLAYBACK_READY, this.name);
42018
42065
  }
42019
42066
  _recover(evt, data, error) {
42020
- assert(this._hls, 'Hls.js instance is not available');
42067
+ assert(this._hls, 'HLS.js is not initialized');
42021
42068
  if (!this._recoveredDecodingError) {
42022
42069
  this._recoveredDecodingError = true;
42023
42070
  this._hls.recoverMediaError();
@@ -42180,10 +42227,6 @@ class HlsPlayback extends BasePlayback {
42180
42227
  details: data.details,
42181
42228
  });
42182
42229
  error.level = PlayerError.Levels.WARN;
42183
- // TODO check
42184
- // if (data.error instanceof MediaError && data.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) {
42185
- // error.code = PlaybackErrorCode.MediaSourceUnavailable
42186
- // }
42187
42230
  this._recover(evt, data, error);
42188
42231
  break;
42189
42232
  default:
@@ -42325,7 +42368,7 @@ class HlsPlayback extends BasePlayback {
42325
42368
  }
42326
42369
  }
42327
42370
  _fillLevels() {
42328
- assert.ok(this._hls, 'Hls.js instance is not available');
42371
+ assert.ok(this._hls, 'HLS.js is not initialized');
42329
42372
  this._levels = this._hls.levels.map((level, index) => {
42330
42373
  return {
42331
42374
  level: index, // or level.id?
@@ -42526,6 +42569,34 @@ class HlsPlayback extends BasePlayback {
42526
42569
  }));
42527
42570
  this.stop();
42528
42571
  }
42572
+ get audioTracks() {
42573
+ assert.ok(this._hls, 'HLS.js is not initialized');
42574
+ return this._hls.audioTracks.map(toClapprTrack);
42575
+ }
42576
+ // @ts-expect-error
42577
+ get currentAudioTrack() {
42578
+ assert.ok(this._hls, 'HLS.js is not initialized');
42579
+ const idx = this._hls.audioTrack;
42580
+ const track = this._hls.audioTracks[idx]; // TODO or find by .id == idx?
42581
+ if (track) {
42582
+ return toClapprTrack(track);
42583
+ }
42584
+ return null;
42585
+ }
42586
+ switchAudioTrack(id) {
42587
+ assert.ok(this._hls, 'HLS.js is not initialized');
42588
+ this._hls.audioTrack = Number(id); // TODO or find index by .id == id?
42589
+ }
42590
+ _onAudioTracksUpdated(_, data) {
42591
+ trace(`${T$2} onAudioTracksUpdated`);
42592
+ this.trigger(Events$1.PLAYBACK_AUDIO_AVAILABLE, data.audioTracks.map(toClapprTrack));
42593
+ }
42594
+ _onAudioTrackSwitched(_, data) {
42595
+ trace(`${T$2} onAudioTrackSwitched`);
42596
+ // @ts-ignore
42597
+ const track = this._hls.audioTracks[data.id];
42598
+ this.trigger(Events$1.PLAYBACK_AUDIO_CHANGED, toClapprTrack(track));
42599
+ }
42529
42600
  }
42530
42601
  HlsPlayback.canPlay = function (resource, mimeType) {
42531
42602
  if (!isHlsSource(resource, mimeType)) {
@@ -42533,6 +42604,14 @@ HlsPlayback.canPlay = function (resource, mimeType) {
42533
42604
  }
42534
42605
  return Hls.isSupported();
42535
42606
  };
42607
+ function toClapprTrack(t) {
42608
+ return {
42609
+ id: String(t.id),
42610
+ language: t.lang ?? '',
42611
+ kind: t.type === 'main' ? 'main' : 'description', // TODO check
42612
+ label: t.name,
42613
+ };
42614
+ }
42536
42615
 
42537
42616
  const T$1 = 'playback.html5_video';
42538
42617
  const STALL_TIMEOUT = 15000;
@@ -42553,10 +42632,6 @@ class HTML5Video extends BasePlayback {
42553
42632
  if (i18n &&
42554
42633
  !errorData.UI &&
42555
42634
  errorData.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) {
42556
- // errorData.UI = {
42557
- // title: i18n.t('no_broadcast'),
42558
- // message: errorData.message,
42559
- // }
42560
42635
  errorData.code = PlaybackErrorCode.MediaSourceUnavailable;
42561
42636
  }
42562
42637
  return super.createError(errorData, { ...options, useCodePrefix: false });
@@ -42612,6 +42687,59 @@ class HTML5Video extends BasePlayback {
42612
42687
  this.stallTimerId = null;
42613
42688
  }
42614
42689
  }
42690
+ get audioTracks() {
42691
+ const tracks = this.el.audioTracks;
42692
+ const supported = !!tracks;
42693
+ trace(`${T$1} get audioTracks`, { supported });
42694
+ const retval = [];
42695
+ if (supported) {
42696
+ for (let i = 0; i < tracks.length; i++) {
42697
+ const track = tracks[i];
42698
+ retval.push({
42699
+ id: track.id,
42700
+ label: track.label,
42701
+ language: track.language,
42702
+ kind: track.kind, // TODO check
42703
+ });
42704
+ }
42705
+ }
42706
+ return retval;
42707
+ }
42708
+ // @ts-expect-error
42709
+ get currentAudioTrack() {
42710
+ const tracks = this.el.audioTracks;
42711
+ const supported = !!tracks;
42712
+ trace(`${T$1} get currentAudioTrack`, {
42713
+ supported,
42714
+ });
42715
+ if (supported) {
42716
+ for (let i = 0; i < tracks.length; i++) {
42717
+ const track = tracks[i];
42718
+ if (track.enabled) {
42719
+ return {
42720
+ id: track.id,
42721
+ label: track.label,
42722
+ language: track.language,
42723
+ kind: track.kind,
42724
+ };
42725
+ }
42726
+ }
42727
+ }
42728
+ return null;
42729
+ }
42730
+ switchAudioTrack(id) {
42731
+ const tracks = this.el.audioTracks;
42732
+ const supported = !!tracks;
42733
+ trace(`${T$1} switchAudioTrack`, {
42734
+ supported,
42735
+ });
42736
+ if (supported) {
42737
+ for (let i = 0; i < tracks.length; i++) {
42738
+ const track = tracks[i];
42739
+ track.enabled = track.id === id;
42740
+ }
42741
+ }
42742
+ }
42615
42743
  }
42616
42744
 
42617
42745
  // TODO consider allowing the variation of the order of playback modules
@@ -43085,7 +43213,7 @@ class Player {
43085
43213
  }
43086
43214
  }
43087
43215
 
43088
- var version$1 = "2.20.22";
43216
+ var version$1 = "2.21.3";
43089
43217
 
43090
43218
  var packages = {
43091
43219
  "node_modules/@clappr/core": {