Skip to content

Commit

Permalink
fix: VTT line styling failing, invalid snapToLines value
Browse files Browse the repository at this point in the history
  • Loading branch information
bwallberg committed Apr 6, 2023
1 parent 36af412 commit ec24961
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/streaming/text/TextTracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ function TextTracks(config) {
if (currentItem.styles.line !== undefined && 'line' in cue) {
cue.line = currentItem.styles.line;
}
if (currentItem.styles.snapToLines !== undefined && 'snapToLines' in cue) {
cue.snapToLines = currentItem.styles.snapToLines;
}
if (currentItem.styles.position !== undefined && 'position' in cue) {
cue.position = currentItem.styles.position;
}
Expand Down
7 changes: 6 additions & 1 deletion src/streaming/utils/VTTParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,19 @@ function VTTParser() {
arr.forEach(function (element) {
if (element.split(/:/).length > 1) {
let val = element.split(/:/)[1];
let isPercentage = false;
if (val && val.search(/%/) != -1) {
isPercentage = true;
val = parseInt(val.replace(/%/, ''), 10);
}
if (element.match(/align/) || element.match(/A/)) {
styleObject.align = val;
}
if (element.match(/line/) || element.match(/L/) ) {
styleObject.line = val;
styleObject.line = val === 'auto' ? val : parseInt(val, 10);
if (isPercentage) {
styleObject.snapToLines = false;
}
}
if (element.match(/position/) || element.match(/P/) ) {
styleObject.position = val;
Expand Down

0 comments on commit ec24961

Please sign in to comment.