Skip to content

Commit 755e72b

Browse files
authored
fix: remove text tracks fallback (#905)
1 parent b32a7c8 commit 755e72b

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/plugins/text-tracks-manager/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ function textTracksManager() {
8585
});
8686
};
8787

88-
const createUrlFallbacks = () => {
89-
if (src) return [src, undefined];
90-
if (type !== 'transcript') return [];
88+
const createSourceUrl = () => {
89+
if (src) return src;
90+
if (type !== 'transcript') return undefined;
9191

9292
const source = player.cloudinary.source();
9393
const publicId = source.publicId();
@@ -96,15 +96,15 @@ function textTracksManager() {
9696
const baseUrl = getTranscriptionFileUrl(urlPrefix, deliveryType, publicId);
9797
const localizedUrl = srclang ? getTranscriptionFileUrl(urlPrefix, deliveryType, publicId, srclang) : null;
9898

99-
return localizedUrl ? [localizedUrl, baseUrl] : [baseUrl, undefined];
99+
return localizedUrl ? localizedUrl : baseUrl;
100100
};
101101

102102
createTextTrackData(track, async (signal) => {
103103
updateTextTrackStatusToPending(track);
104104

105-
const urls = createUrlFallbacks();
105+
const sourceUrl = createSourceUrl();
106106
const response = await fetchFileContent(
107-
...urls,
107+
sourceUrl,
108108
{
109109
signal,
110110
polling: type === 'transcript' && !src,

src/plugins/text-tracks-manager/utils.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export const fetchFileContent = async (
22
url,
3-
fallbackUrl,
43
config = {}
54
) => {
65
const {
@@ -15,21 +14,21 @@ export const fetchFileContent = async (
1514

1615
let attempts = 0;
1716

18-
const attemptFetch = async (currentUrl) => {
17+
const attemptFetch = async () => {
1918
if (signal?.aborted) {
2019
throw new DOMException('Aborted', 'AbortError');
2120
}
2221

2322
attempts++;
2423
onAttempt?.(attempts);
2524

26-
const response = await fetch(currentUrl, { signal });
25+
const response = await fetch(url, { signal });
2726

2827
if (response.status === 202 && polling) {
2928
if (attempts < maxAttempts) {
3029
return new Promise((resolve, reject) => {
3130
const timeoutId = setTimeout(() => {
32-
attemptFetch(url).then(resolve).catch(reject);
31+
attemptFetch().then(resolve).catch(reject);
3332
}, interval);
3433

3534
signal?.addEventListener('abort', () => {
@@ -43,10 +42,7 @@ export const fetchFileContent = async (
4342
}
4443

4544
if (!response.ok) {
46-
if (fallbackUrl) {
47-
return attemptFetch(fallbackUrl);
48-
}
49-
throw new Error(`Failed fetching from ${currentUrl} with status code ${response.status}`);
45+
throw new Error(`Failed fetching from ${url} with status code ${response.status}`);
5046
}
5147

5248
const text = await response.text();
@@ -55,7 +51,7 @@ export const fetchFileContent = async (
5551
};
5652

5753
try {
58-
return await attemptFetch(url);
54+
return await attemptFetch();
5955
} catch (error) {
6056
if (error.name === 'AbortError') {
6157
console.warn('Polling aborted');

0 commit comments

Comments
 (0)