Skip to content

Commit

Permalink
fix(withHTMLSubtitles): fallbackUrl issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Feb 13, 2025
1 parent 9be3a9e commit 68f3790
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/withHTMLSubtitles/withHTMLSubtitles.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ function withHTMLSubtitles(Video) {
selectedTrackId = selectedTrack.id;
delay = 0;

function getSubtitlesData(track) {
if (typeof track.url === 'string') {
return fetch(track.url)
function getSubtitlesData(track, isFallback) {
var url = isFallback ? selectedTrack.fallbackUrl : track.url;

if (typeof url === 'string') {
return fetch(url)
.then(function(resp) {
if (resp.ok) {
return resp.text();
Expand All @@ -252,7 +254,7 @@ function withHTMLSubtitles(Video) {
}

function loadSubtitles(track, isFallback) {
getSubtitlesData(track)
getSubtitlesData(track, isFallback)
.then(function(text) {
return subtitlesConverter.convert(text);
})
Expand Down

0 comments on commit 68f3790

Please sign in to comment.