@playkit-js/transcript 3.5.12 → 3.5.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/transcript",
3
- "version": "3.5.12",
3
+ "version": "3.5.13",
4
4
  "main": "dist/playkit-transcript.js",
5
5
  "license": "AGPL-3.0",
6
6
  "private": false,
@@ -129,7 +129,10 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
129
129
  }
130
130
  });
131
131
  if (captionData.length) {
132
- this._addCaptionData(captionData);
132
+ // take metadata from the first caption, as all captions in captionData have the same language and label
133
+ const captionMetadata = payload.cues[0].metadata;
134
+ const captionKey = this._makeCaptionKey(captionMetadata.language, captionMetadata.label);
135
+ this._addCaptionData(captionData, captionKey);
133
136
  this._addTranscriptItem();
134
137
  }
135
138
  };
@@ -151,9 +154,12 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
151
154
  this._updateTranscriptPanel();
152
155
  };
153
156
 
154
- private _addCaptionData = (newData: CuePointData[]) => {
157
+ private _addCaptionData = (newData: CuePointData[], captionKey: string) => {
155
158
  this._activeCaptionMapId = this._getCaptionMapId();
156
- this._captionMap.set(this._activeCaptionMapId, this._sanitizeCaptions(newData));
159
+ const oldData = this._captionMap.get(captionKey);
160
+ const newSanitizedData = this._sanitizeCaptions(newData);
161
+ // set the captions data according to the captionKey param
162
+ this._captionMap.set(captionKey, oldData ? [...oldData, ...newSanitizedData] : newSanitizedData);
157
163
  this._isLoading = false;
158
164
  clearTimeout(this._loadingTimeoutId);
159
165
  this._updateTranscriptPanel();
@@ -168,9 +174,13 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
168
174
  const activeTextTrack = allTextTracks.find(track => track.active);
169
175
  if (activeTextTrack?.language === 'off') {
170
176
  // use 1st captions from text-track list
171
- return `${allTextTracks[0]?.language}-${allTextTracks[0]?.label}`;
177
+ return this._makeCaptionKey(allTextTracks[0]?.language, allTextTracks[0]?.label);
172
178
  }
173
- return `${activeTextTrack?.language}-${activeTextTrack?.label}`;
179
+ return this._makeCaptionKey(activeTextTrack?.language, activeTextTrack?.label);
180
+ };
181
+
182
+ private _makeCaptionKey = (language?: string, label?: string): string => {
183
+ return `${language}-${label}`;
174
184
  };
175
185
 
176
186
  private _activatePlugin = (isFirstOpen = false) => {