You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to add a closed caption button to the YouTube player to enable/disable captions dynamically. Additionally, I want to allow users to select the available languages for captions.
I already have access to the available languages through an internal API, but I'm facing an issue with changing the caption language or enabling/disabling captions after the player is initialized.
Issue/Blocker:
It seems that changing the caption language or toggling captions is only possible through the IFramePlayerOptions, which can only be set during the player's initialization.
The library does not support reinitializing the player after it’s been created.
Destroying and recreating the player to apply new IFramePlayerOptions results in a glitchy experience.
Question: Is there a way to dynamically update the caption settings (enable/disable and change languages) without destroying and recreating the player? Or, is there a recommended solution to handle this more smoothly?
Any insights or workarounds would be greatly appreciated! Thank you.
The text was updated successfully, but these errors were encountered:
HamzaIsrar12
changed the title
Feature Request: Closed Caption Button and Dynamic Language Change for Captions
Closed Caption Button and Dynamic Language Change for Captions
Oct 20, 2024
You can get a list of available captions and select any of them without recreating the player.
I dont know why they didnt mention this in the documentation but there are options called tracklist and track.
First of all set cc_load_policy to 1 in iframe player settings.
You should use codes below inside onApiChange because onApiChange event fires when captions or other modules loaded.
Now that you have a list of available captions you can choose them with this:
player.setOption('captions','track',/*put selected json object from the list here*/);
To turn off captions programatically you can use this:
player.setOption('captions','track',{});
Obviously, to implement these changes you are gonna have to edit the library.
Implementing neccesary javascript interfaces to control the player from java or kotlin is for you to figure out.
Hi Pier,
I would like to add a closed caption button to the YouTube player to enable/disable captions dynamically. Additionally, I want to allow users to select the available languages for captions.
I already have access to the available languages through an internal API, but I'm facing an issue with changing the caption language or enabling/disabling captions after the player is initialized.
Issue/Blocker:
IFramePlayerOptions
, which can only be set during the player's initialization.IFramePlayerOptions
results in a glitchy experience.Question: Is there a way to dynamically update the caption settings (enable/disable and change languages) without destroying and recreating the player? Or, is there a recommended solution to handle this more smoothly?
Any insights or workarounds would be greatly appreciated! Thank you.
The text was updated successfully, but these errors were encountered: