@grfzhl/vue-hls-player 1.1.20 → 1.1.21

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/README.md CHANGED
@@ -207,6 +207,8 @@ At the moment the following attribute are supported:
207
207
  ```
208
208
 
209
209
  ### Last release:
210
+ v1.1.21
211
+ - Added more tolerant processing for .txt transcripts to allow empty lines as narrators
210
212
  v1.1.20
211
213
  - Stability and UI style improvements for Language switch
212
214
  v1.1.19
@@ -274,9 +274,13 @@ async function parseTXT(fileUrl) {
274
274
  const lines = text.split('\n');
275
275
  let cue = null;
276
276
  let dialog = null;
277
+ let speakerRowSet = false;
278
+ let timeStampRowSet = false;
277
279
  for (let i = 0; i < lines.length; i++) {
278
280
  const line = lines[i].trim();
279
- if (!line) continue;
281
+ if(timeStampRowSet && speakerRowSet) {
282
+ if (!line) continue;
283
+ }
280
284
 
281
285
  /**
282
286
  * extract every transcript part by time
@@ -292,16 +296,20 @@ async function parseTXT(fileUrl) {
292
296
  text: '',
293
297
  speaker: ''
294
298
  }
295
- } else if (cue && dialog.text == '' && dialog.speaker == '') {
299
+ timeStampRowSet = true;
300
+ } else if (cue && dialog.text == '' && !speakerRowSet) {
301
+ speakerRowSet = true;
296
302
  dialog.speaker = line;
297
- } else if (cue && dialog.speaker !== '') {
303
+ } else if (cue && speakerRowSet) {
298
304
  dialog.text += line + ' ';
299
305
  }
300
306
 
301
- if (cue && (!lines[i + 1] || lines[i + 1].match(/^\d{2}:\d{2}:\d{2}:\d{2} - \d{2}:\d{2}:\d{2}:\d{2}/))) {
307
+ if (cue && speakerRowSet && timeStampRowSet && (!lines[i + 1] || lines[i + 1].match(/^\d{2}:\d{2}:\d{2}:\d{2} - \d{2}:\d{2}:\d{2}:\d{2}/))) {
302
308
  cue.dialog.push(dialog);
303
309
  cues.push(cue);
304
310
  cue = null;
311
+ speakerRowSet = false;
312
+ timeStampRowSet = false;
305
313
  }
306
314
  }
307
315
  return cues;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grfzhl/vue-hls-player",
3
3
  "private": false,
4
- "version": "1.1.20",
4
+ "version": "1.1.21",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"