-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: text displayer config overrides for text color/background color #8265
base: main
Are you sure you want to change the base?
feat: text displayer config overrides for text color/background color #8265
Conversation
Hi @david-hm-morgan, Thank you for the PR! This is initially how I had this in mind, but I started doubting adding defaults for several reasons. Text displayers are a visual representation of a Using The idea to add defaulting when there's an explicit way to modify a cue (and thus its visual representation) doesn't sit well with me anymore. I like the idea to change its appearance unrelated to what text displayer is used. Another thing is that First, I'd like to figure out if there's a case where we wouldn't want to alter the cue through Happy to discuss this further, let me know your thoughts. |
I see an improvement over your solution, and that is that you can change this on the fly. @david-hm-morgan Do you want to use this to change cues dynamically even while they are on screen? |
Right, I think it's fair to assume people want to change defaults on the fly (eg; a default style menu à la Prime). Would it make sense to add |
Incremental code coverage: 100.00% |
@david-hm-morgan @matvp91 Then I'd prefer CSSStyleDeclaration instead this PR |
@gkatsev wouldn't |
@matvp91 the key here is to choose what you want to override or not. I.e., I want to make sure that background color is set to my color in all cases, but everything else can be what the caption says. |
And as I mention, it's mostly a "nice-to-have". Having the overrides is more important in the first place. The "allow video to override" type setting can come later. Also, I mention it for shaka because due to how shaka parses cues, it may have an easier time around that setting compared to other player projects. |
I agree, it's reasonable to add something like: player.configure({
textDisplayer: {
defaultStyles: /* @type CSSStyleDeclaration */ {},
forcedStyles: /* @type CSSStyleDeclaration */ {},
},
}); WDYT? |
@@ -705,7 +747,7 @@ shaka.text.UITextDisplayer = class { | |||
|
|||
style.webkitTextStrokeColor = cue.textStrokeColor; | |||
style.webkitTextStrokeWidth = cue.textStrokeWidth; | |||
style.color = cue.color; | |||
style.color = this.readabilityTextColor_(cue.color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to drop a separate function for each style property. You can add a default styles map to player_configuration.js. This would make it a one liner:
style.color = cue.color || this.config_.textColor
We can maybe introduce a helper function later on to resolve the correct value by key name (as the same logic would apply for all style properties). Especially if we're going to distinguish default vs. forced.
@matvp91 FYI I've other tasks in hand currently, it might be a little while before I can circle back to this topic |
Following on and extending the style of config of text displayer introduced with #8242 .
FYI @matvp91