This commit is contained in:
parent
3e20780b60
commit
83ab76c7d3
3 changed files with 72 additions and 12 deletions
|
|
@ -147,12 +147,32 @@
|
|||
enableWorker: true,
|
||||
lowLatencyMode: true,
|
||||
backBufferLength: 90,
|
||||
// Increased retry settings for LLHLS resilience
|
||||
fragLoadingMaxRetry: 6,
|
||||
fragLoadingRetryDelay: 1000,
|
||||
manifestLoadingMaxRetry: 4,
|
||||
levelLoadingMaxRetry: 4,
|
||||
maxBufferLength: 30,
|
||||
maxBufferHole: 0.5,
|
||||
xhrSetup: function(xhr, url) {
|
||||
// Only add token if not already present (segments don't have it)
|
||||
if (viewerToken && url.includes('/app/') && !url.includes('token=')) {
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
xhr.open('GET', url + separator + 'token=' + encodeURIComponent(viewerToken), true);
|
||||
let finalUrl = url;
|
||||
|
||||
// Use URL API for proper parameter handling to avoid encoding issues
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
if (viewerToken && url.includes('/app/') && !urlObj.searchParams.has('token')) {
|
||||
urlObj.searchParams.set('token', viewerToken);
|
||||
finalUrl = urlObj.toString();
|
||||
}
|
||||
} catch (e) {
|
||||
// Fallback for relative URLs
|
||||
if (viewerToken && url.includes('/app/') && !url.includes('token=')) {
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
finalUrl = url + separator + 'token=' + encodeURIComponent(viewerToken);
|
||||
}
|
||||
}
|
||||
|
||||
xhr.open('GET', finalUrl, true);
|
||||
xhr.withCredentials = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,11 +162,32 @@
|
|||
enableWorker: true,
|
||||
lowLatencyMode: true,
|
||||
backBufferLength: 30,
|
||||
// Increased retry settings for LLHLS resilience
|
||||
fragLoadingMaxRetry: 6,
|
||||
fragLoadingRetryDelay: 1000,
|
||||
manifestLoadingMaxRetry: 4,
|
||||
levelLoadingMaxRetry: 4,
|
||||
maxBufferLength: 30,
|
||||
maxBufferHole: 0.5,
|
||||
xhrSetup: function(xhr, url) {
|
||||
if (token && url.includes('/app/') && !url.includes('token=')) {
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
xhr.open('GET', url + separator + 'token=' + encodeURIComponent(token), true);
|
||||
let finalUrl = url;
|
||||
|
||||
// Use URL API for proper parameter handling to avoid encoding issues
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
if (token && url.includes('/app/') && !urlObj.searchParams.has('token')) {
|
||||
urlObj.searchParams.set('token', token);
|
||||
finalUrl = urlObj.toString();
|
||||
}
|
||||
} catch (e) {
|
||||
// Fallback for relative URLs
|
||||
if (token && url.includes('/app/') && !url.includes('token=')) {
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
finalUrl = url + separator + 'token=' + encodeURIComponent(token);
|
||||
}
|
||||
}
|
||||
|
||||
xhr.open('GET', finalUrl, true);
|
||||
xhr.withCredentials = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,13 +356,32 @@
|
|||
enableWorker: true,
|
||||
lowLatencyMode: true,
|
||||
backBufferLength: 90,
|
||||
// Increased retry settings for LLHLS resilience
|
||||
fragLoadingMaxRetry: 6,
|
||||
fragLoadingRetryDelay: 1000,
|
||||
manifestLoadingMaxRetry: 4,
|
||||
levelLoadingMaxRetry: 4,
|
||||
maxBufferLength: 30,
|
||||
maxBufferHole: 0.5,
|
||||
xhrSetup: function(xhr, url) {
|
||||
// Add viewer token to HLS segment requests (not playlists, which already have it)
|
||||
// Only add if token is not already present in the URL
|
||||
if (viewerToken && url.includes('/app/') && !url.includes('token=')) {
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
xhr.open('GET', url + separator + 'token=' + encodeURIComponent(viewerToken), true);
|
||||
let finalUrl = url;
|
||||
|
||||
// Use URL API for proper parameter handling to avoid encoding issues
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
if (viewerToken && url.includes('/app/') && !urlObj.searchParams.has('token')) {
|
||||
urlObj.searchParams.set('token', viewerToken);
|
||||
finalUrl = urlObj.toString();
|
||||
}
|
||||
} catch (e) {
|
||||
// Fallback for relative URLs
|
||||
if (viewerToken && url.includes('/app/') && !url.includes('token=')) {
|
||||
const separator = url.includes('?') ? '&' : '?';
|
||||
finalUrl = url + separator + 'token=' + encodeURIComponent(viewerToken);
|
||||
}
|
||||
}
|
||||
|
||||
xhr.open('GET', finalUrl, true);
|
||||
xhr.withCredentials = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue