shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.19k stars 1.34k forks source link

Subtitles are not centered #4015

Closed avelad closed 2 years ago

avelad commented 2 years ago

Have you read the FAQ and checked for duplicate open issues? Yes

What version of Shaka Player are you using? 3.3.2

Can you reproduce the issue with our latest release version? Yes

Can you reproduce the issue with the latest code from main? Yes

Are you using the demo app or your own custom app? Both

If custom app, can you reproduce the issue using our demo app? Yes

What browser and OS are you using? Any with MSE support

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

What are the manifest and license server URIs?

N/A

What configuration are you using? What is the output of player.getConfiguration()?

Default

What did you do?

Load a TTML subtitle without tts:textAlign Example:

<?xml version="1.0" encoding="utf-8"?>
<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:tt="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:tts="http://www.w3.org/ns/ttml#styling">
    <head>
        <metadata>
            <ttm:title/>
            <ttm:desc/>
            <ttm:copyright/>
        </metadata>
        <styling>
            <style xml:id="style0"/>
        </styling>
        <layout>
            <region tts:extent="48% 8%" tts:fontFamily="monospaceSerif" tts:origin="24% 76%" xml:id="region01"/>
            <region tts:extent="78% 8%" tts:fontFamily="monospaceSerif" tts:origin="9% 84%" xml:id="region02"/>
        </layout>
    </head>
    <body>
        <div>
            <p begin="456628:17:04.888" end="456628:17:06.522" region="region01" style="style0" xml:id="caption2713">- ¡Egipto! ¿Cómo es?</p>
            <p begin="456628:17:04.888" end="456628:17:06.522" region="region02" style="style0" xml:id="caption2714">- ¡Fantástico! Hay muchas cosas.</p>
        </div>
    </body>
</tt>

What did you expect to happen? The subtitle should be centered by default.

What actually happened?

Text align value by default in TTML parser is START https://github.com/shaka-project/shaka-player/blob/main/lib/text/ttml_text_parser.js#L548 image

I know that ShakaPlayer follows the specification, and also puts a comment in the code, but the rest of the players on the market by default the subtitles are centered, would you admit a PR to make this change?

joeyparrish commented 2 years ago

Sounds good to me. Thanks!