-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for forced subtitles #2938
Conversation
@joeyparrish I have added the translations of languages that I know. I don't know if it is enough or should I use google translate. |
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.
This appears to just parse the setting, not change any behavior. It will show the "forced" label in the track list, but the track won't actually be shown unless the user enables them. Are you going to send another PR to actually show the tracks?
@@ -3846,6 +3848,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget { | |||
shaka.util.Error.Code.TEXT_ONLY_WEBVTT_SRC_EQUALS, | |||
mimeType); | |||
} | |||
if (forced) { | |||
kind = 'forced'; |
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.
Is this some Apple feature to force the cues to be displayed? Wouldn't it be better to just set the mode
to showing
? This seams platform-specific and doesn't appear in the HTML spec.
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.
This is the way Safari works. I have seen it testing with https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8 and other private streams.
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.
The I suggest at least a comment. I'd also be concerned with browser support. This is supposed to be an enum value, so some browsers may throw if we set to an invalid value. Maybe you should set the kind
after we set the original value and do it inside a try-catch.
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.
This change is only used in src = and since you have to create a track element a try-catch is not effective in this case.
Tried an unknown kind in Chrome and it works fine.
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.
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.
Here's the correct html spec issue link: whatwg/html#4472
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.
I would suggest replacing the comment with a link to the HTML spec issue.
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.
Done!
@@ -473,6 +475,9 @@ shaka.util.StreamUtils = class { | |||
if (textTrack.kind) { | |||
track.roles = [textTrack.kind]; | |||
} | |||
if (textTrack.kind == 'forced') { | |||
track.forced = true; |
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.
Like above, is this Apple-specific? I don't see anything in the HTML spec for this. Do you have any documentation you could link to, or is this just from trying it?
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.
This is the way Safari works. I have seen it testing with https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8 and other private streams.
And yes, the translations are fine. You just need to edit the |
Yes, my idea is to send another PR to handle this behavior. But I want to go little by little and without anything breaking. |
@TheModMaker Are any more changes necessary to approve this RP? |
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.
Just change the comments and LGTM.
ui/language_utils.js
Outdated
@@ -95,6 +98,9 @@ shaka.ui.LanguageUtils = class { | |||
|
|||
span.textContent = | |||
shaka.ui.LanguageUtils.getLanguageName(language, localization); | |||
if (forced) { | |||
span.textContent += ' (' + forcedString + ')'; | |||
} |
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.
This is mostly overwritten below and the LANGUAGE_ROLE case gets this twice. So I think it would be better to put this after the switch so all cases get it exactly once.
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.
For the LABEL format it does not apply, but I have changed it to fit what you say.
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.
LGTM. Thanks for working on this.
All tests passed! |
Add support to forced subtitles in HLS, DASH and src=
Resolves: #2916 & #2122