Text displayers *************** Code samples: * Subtitle text styling (https://raw.githubusercontent.com/castlabs/prestoplay-web-code-samples/refs/heads/main/examples/subtitles/text_style.js): font, color, background, and edge style through text style options. PRESTOplay for Web Apps renders text cues with one of two displayers: the HTML displayer, which is recommended, or the browser's native text displayer. HTML displayer ============== The HTML displayer renders text cues using the HTML surface, with rich styling capabilities and consistent results across browsers. It has strong support for rendering parsed TTML, SMPTE-TT, IMSC1, WebVTT, and SRT cues. To use it: 1. Add the PRESTOplay default styles to your page: 2. Import the HTML Cue module: import "@castlabs/prestoplay/cl.htmlcue"; The HTML text displayer is used by default once "@castlabs/prestoplay/cl.htmlcue" is imported. Set "enableHtmlCue" to "false" in the player configuration to change this. Styling ------- Styles apply in this order, from lowest to highest priority: 1. Player styles 2. Website styles 3. Embedded styles 4. Text style options Player styles come from "clpp.styles.css" and are required — they provide default styles for text cues and regions. Override the default styles with your own stylesheet by extending the ".clpp-text-container", ".clpp-text-cue", or ".clpp-text-cue-region" classes. Website styles take priority over default styles. A text track can contain embedded styles, which take priority over website and default styles. Text style options, set in the player configuration or through "player.getTextDisplayer()", take priority over embedded, website, and default styles. Use these to let your users customize the look and feel of subtitles. Font size --------- The HTML displayer adjusts a base font size to the container size for responsive design. By default, the font size is 7% of the container height. Adjust it in the player configuration: const playerConfig = { // ... textStyle: { fontSizePercent: 0.03 } }; Native text displayer ===================== Styling ------- Style text cues using text style options in the player configuration: const playerConfig = { // ... textStyle: { backgroundColor: 'rgba(207, 0, 15, 0.75)', fontFamily: 'monospace', fontColor: 'blue', fontSize: '1.2em', edgeColor: 'green', edgeType: clpp.text.EdgeType.DROP_SHADOW } } Or style cues on the fly through a text displayer instance: player.getTextDisplayer().setFontColor('blue'); Native text-cue styling has some constraints: * It requires Edge 19 or later. * Background color and opacity are configurable on browsers other than Safari (macOS/iPadOS/iOS) and Chrome (macOS). Use the HTML displayer to style text cues consistently across all supported browsers.