mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-10 02:08:21 +00:00
Allow set subtitle language from url parameter (#2935)
* allow set subtitle language from url parameter As user, I want to set subtitles language from url parameters, So i do not need to subtitle language each time i switch instances for now you can set `subtitles=xx` (example: `subtitles=en`) on url parameter to set video subtitle language. full url example: https://piped.video/watch?v=6stlCkUDG_s&subtitles=en i choose query `subtitles` so it's compatible with [invidious url parameter](https://docs.invidious.io/url-parameters/) this is especially useful when you have addons like redirector improvement over https://github.com/TeamPiped/Piped/issues/2669 and https://github.com/TeamPiped/Piped/issues/223 * cleaning code * looks simpler and more self-explaining fix suggested on https://github.com/TeamPiped/Piped/pull/2937#discussion_r1325072807
This commit is contained in:
parent
a2e2c74a38
commit
5b4fb38c85
@ -594,6 +594,16 @@ export default {
|
||||
|
||||
const autoDisplayCaptions = this.getPreferenceBoolean("autoDisplayCaptions", false);
|
||||
this.$player.setTextTrackVisibility(autoDisplayCaptions);
|
||||
|
||||
const prefSubtitles = this.getPreferenceString("subtitles", "");
|
||||
if (prefSubtitles !== "") {
|
||||
const textTracks = this.$player.getTextTracks();
|
||||
const subtitleIdx = textTracks.findIndex(textTrack => textTrack.language == prefSubtitles);
|
||||
if (subtitleIdx != -1) {
|
||||
this.$player.setTextTrackVisibility(true);
|
||||
this.$player.selectTextTrack(textTracks[subtitleIdx]);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
|
Loading…
Reference in New Issue
Block a user