@mediakind/mkplayer 1.0.21 → 1.0.23

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/src/MKPlayer.ts CHANGED
@@ -159,13 +159,25 @@ export class MKPlayer {
159
159
  },
160
160
  subtitles: (track) => {
161
161
  console.log(track);
162
- if (this.stream.labelConfig && this.stream.labelConfig.captions && this.stream.labelConfig.captions[track.lang]) {
163
- return this.stream.labelConfig.captions[track.lang];
164
- } else {
162
+ try {
163
+ if (this.stream.labelConfig && this.stream.labelConfig.captions) {
164
+ let filtered = this.stream.labelConfig.captions.filter((value) => value.language === track.lang);
165
+ if (filtered && filtered.length === 1) {
166
+ return filtered[0].name;
167
+ } else if (filtered && filtered.length > 1) {
168
+ filtered = filtered.filter((value) => value.id === track.id);
169
+ if (filtered && filtered[0]) {
170
+ return filtered[0].name;
171
+ }
172
+ }
173
+ }
174
+ } catch (e) {
165
175
  return track.lang;
176
+
166
177
  }
178
+ return track.lang;
179
+ },
167
180
  },
168
- },
169
181
  };
170
182
 
171
183
  if (stream.assetIdentifier) {
@@ -292,7 +304,7 @@ export class MKPlayer {
292
304
  * returns the current player version
293
305
  */
294
306
  version(): string {
295
- return '1.0.21';
307
+ return '1.0.23';
296
308
  }
297
309
 
298
310
  private selectUrl(): string {