zhw2590582 / ArtPlayer

:art: ArtPlayer.js is a modern and full featured HTML5 video player
https://artplayer.org
MIT License
2.42k stars 260 forks source link

How to add subtitle setting dynamically? #752

Closed Tescan-group closed 2 months ago

Tescan-group commented 2 months ago

Hey there, could you help me out on how to add a subtitle menu like you have in the player at artplayer.org settings dynamically?

I want to add it in this JS code without having to create a new player if possible;

document.getElementById("ChangeServerButton").addEventListener("click", function() {
                art.switchUrl('<?php echo $videoUrl; ?>');
                art.quality = [];
                <?php if(isset($subtitles['English'])) : ?>
                    art.subtitle.url = '<?php echo $subtitles['English']; ?>';
                    art.subtitle.style({
                        color: '#fe9200',
                        fontSize: '25px',
                    });
                <?php endif; ?>

            });

I basically want to add the subtitle option on the screenshot below without re-building the player;

image
zhw2590582 commented 2 months ago

You can update settings:

https://artplayer.org/document/en/component/setting.html#updates