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

Updating video subtitles dynamically #329

Closed
Exelenz9 opened this issue Feb 10, 2018 · 4 comments
Closed

Updating video subtitles dynamically #329

Exelenz9 opened this issue Feb 10, 2018 · 4 comments

Comments

@Exelenz9
Copy link

Hi. I have a problem with setting video subtitles at runtime via React Player.
As I found in docs, subtitles should be set through config -> file -> tracks. When I set them like this it works perfectly:

config={{ file: {
  tracks: [
    {kind: 'subtitles', src: 'subs/subtitles.en.vtt', srcLang: 'en', default: true},
    {kind: 'subtitles', src: 'subs/subtitles.ja.vtt', srcLang: 'ja'},
    {kind: 'subtitles', src: 'subs/subtitles.de.vtt', srcLang: 'de'}
  ]
}}}

However, if I want to set another current subtitles file there is no way to do it. As I understood config is set only once.

Is there any workaround to dynamically update current subtitles?
Thanks

@cookpete
Copy link
Owner

Fixed in 1.1.3 👍

@Exelenz9
Copy link
Author

Thanks!

david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue Dec 23, 2018
david-hub024 pushed a commit to david-hub024/React_VideoPlayer that referenced this issue May 23, 2020
@gmariani
Copy link

gmariani commented Jan 31, 2021

This seems to be an issue still in 2.8.1. Toggling subtitle mode from visible to hidden, or changing the subtitle URL at run time does not trigger the player to update properly. Is there anything special that needs to be done to the config object to trigger the player to update? The VTT file is pulled in using fetch so it is initially empty until the signed url is retrieved for use. Also the subtitle display is controlled via a react state, and while it appears to work properly the actual DOM doesn't update to reflect the change. If the player goes from one video straight into the next, the video itself changes but the subtitles from the previous movie play again unless the page is reloaded.

Here is what my object looks like:

const subtitleURL = useAWSSignedURL(episode.subtitleKey);
const videoConfig = {
        file: {
            attributes: {
                crossOrigin: 'anonymous',
            },
            tracks: [
                {
                    kind: 'subtitles',
                    src: subtitleURL,
                    srcLang: 'en',
                    default: true,
                    mode: settings.subtitles ? 'showing' : 'hidden',
                },
            ],
        },
    };

albanqoku added a commit to albanqoku/react-player that referenced this issue Feb 24, 2021
Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
@haxxxton
Copy link

haxxxton commented Nov 3, 2023

encountering this same issue in Nov 2023. dynamically changing the tracks through a new config doesnt trigger an update in the underlying video element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@haxxxton @cookpete @Exelenz9 @gmariani and others