VTT subtitle positioning omitted
Created by: wallstersson
I ran into an issue when using VTT subs that have positioning information. When testing it in the 2.4.0 reference player the positioning was omitted.
An example VTT line is listed below.
00:00:02.000 --> 00:00:03.500 position:20%
<i><c.green>my text</c></i>
When debugging I located the issue to the following code snippet from the function "addCaptions" in "TextTracks.js".
cue = new Cue(currentItem.start - timeOffset, currentItem.end - timeOffset, currentItem.data);
if (currentItem.styles) {
if (currentItem.styles.align !== undefined && cue.hasOwnProperty('align')) {
cue.align = currentItem.styles.align;
}
if (currentItem.styles.line !== undefined && cue.hasOwnProperty('line')) {
cue.line = currentItem.styles.line;
}
if (currentItem.styles.position !== undefined && cue.hasOwnProperty('position')) {
cue.position = currentItem.styles.position ;
}
if (currentItem.styles.size !== undefined && cue.hasOwnProperty('size')) {
cue.size = currentItem.styles.size;
}
}
In my case cue.hasOwnProperty('position') always returned false, even if I could see in the debugger that the cue object has the property. I guess that this is because the property is inherited from the prototype. I changed this to 'position' in cue and tested it in the sample player project and it works well. But I'm not really sure if this is a correct way of fixing it (I'm no javascript-dev)?
cue = new Cue(currentItem.start - timeOffset, currentItem.end - timeOffset, currentItem.data);
if (currentItem.styles) {
if (currentItem.styles.align !== undefined && 'align' in cue) {
cue.align = currentItem.styles.align;
}
if (currentItem.styles.line !== undefined && 'line' in cue) {
cue.line = currentItem.styles.line;
}
if (currentItem.styles.position !== undefined && 'position' in cue) {
cue.position = currentItem.styles.position ;
}
if (currentItem.styles.size !== undefined && 'size' in cue) {
cue.size = currentItem.styles.size;
}
}