diff --git a/lib/text/ttml_text_parser.js b/lib/text/ttml_text_parser.js index 5cd83ce24f..730202aa0d 100644 --- a/lib/text/ttml_text_parser.js +++ b/lib/text/ttml_text_parser.js @@ -306,9 +306,16 @@ shaka.text.TtmlTextParser = class { const regionId = regionElement.getAttribute('xml:id'); cue.region = cueRegions.filter((region) => region.id == regionId)[0]; } - const imageElement = shaka.text.TtmlTextParser.getElementsFromCollection_( - cueElement, 'backgroundImage', metadataElements, '#', - shaka.text.TtmlTextParser.smpteNs_)[0]; + + let imageElement = null; + for (const nameSpace of shaka.text.TtmlTextParser.smpteNsList_) { + imageElement = shaka.text.TtmlTextParser.getElementsFromCollection_( + cueElement, 'backgroundImage', metadataElements, '#', + nameSpace)[0]; + if (imageElement) { + break; + } + } const isLeaf = nestedCues.length == 0; @@ -1243,12 +1250,14 @@ shaka.text.TtmlTextParser.styleNs_ = 'http://www.w3.org/ns/ttml#styling'; shaka.text.TtmlTextParser.styleEbuttsNs_ = 'urn:ebu:tt:style'; /** - * The namespace URL for SMPTE fields. - * @const {string} + * The supported namespace URLs for SMPTE fields. + * @const {!Array.} * @private */ -shaka.text.TtmlTextParser.smpteNs_ = - 'http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt'; +shaka.text.TtmlTextParser.smpteNsList_ = [ + 'http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt', + 'http://www.smpte-ra.org/schemas/2052-1/2013/smpte-tt', +]; shaka.text.TextEngine.registerParser( 'application/ttml+xml', () => new shaka.text.TtmlTextParser()); diff --git a/test/text/ttml_text_parser_unit.js b/test/text/ttml_text_parser_unit.js index 81f1a1c73b..5174b1fcfe 100644 --- a/test/text/ttml_text_parser_unit.js +++ b/test/text/ttml_text_parser_unit.js @@ -909,6 +909,30 @@ describe('TtmlTextParser', () => { {periodStart: 0, segmentStart: 0, segmentEnd: 0}); }); + it('supports smpte:backgroundImage attribute alt namespace', () => { + verifyHelper( + [ + { + startTime: 62.05, + endTime: 3723.2, + payload: '', + backgroundImage: 'data:image/png;base64,base64EncodedImage', + }, + ], + '' + + '' + + '' + + 'base64EncodedImage' + + '' + + '
' + + '

' + + '

', + {periodStart: 0, segmentStart: 0, segmentEnd: 0}); + }); + it('inserts line breaks for
tags', () => { verifyHelper( [{