Skip to content
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

Default caption on load #4951

Closed
hiren3897 opened this issue Jan 31, 2023 · 5 comments
Closed

Default caption on load #4951

hiren3897 opened this issue Jan 31, 2023 · 5 comments
Labels
status: archived Archived and locked; will not be updated type: question A question from the community

Comments

@hiren3897
Copy link

hiren3897 commented Jan 31, 2023

Have you read the Tutorials?
yes

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

What version of Shaka Player are you using?
v4.3.0

Please ask your question
I add 7 different external subtitles .vtt to the player using

await this.player.addTextTrackAsync(subtitlesTrack.url, subtitlesTrack.language, 'subtitles', subtitlesTrack.mimeType);

What I want is for when the player loads it should have a default subtitle activated.

I have to manually go and select the subtitle.

Is there any way to do that?

I already tried the configurations mentioned below.

preferredTextRole: 'en',
preferredTextLanguage: 'en'
@hiren3897 hiren3897 added the type: question A question from the community label Jan 31, 2023
@joeyparrish
Copy link
Member

I believe that preferred* configs are applied to choose initial tracks, before you call addTextTrackAsync. So you will have to select it yourself. You can use the return value from addTextTrackAsync to call selectTextTrack, though, if I'm not mistaken.

@joeyparrish
Copy link
Member

"On load", your additional tracks don't exist yet, so we can't use the preferences to choose them on load.

@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jan 31, 2023
@hiren3897
Copy link
Author

hiren3897 commented Jan 31, 2023

Okay, thanks for the guidelines,

After the player loads, I can try to selectTextTrack from getTextTracks? but it still doesn't work :(

Still the captions is set to off

Do Have to set track.active -> true?

As I remember I tried this but didn't work` If I'm not mistaken.

@github-actions github-actions bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jan 31, 2023
@joeyparrish
Copy link
Member

You also need to call setTextTrackVisibility(true). Please don't change track.active. That is informational, and active tracks are changed by selectTextTrack() only.

@hiren3897
Copy link
Author

Thanks @joeyparrish
the missing piece was setTextTrackVisibility(true)

It works.
🎉

@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Apr 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: question A question from the community
Projects
None yet
Development

No branches or pull requests

3 participants