AVplay is throwing error(InvalidAccessError: PLAYER_ERROR_INVALID_OPERATION), if video URL is redirecting. Suppose video URL is https:abc.m3u8 and when try to play it, it redirects to https:xyz.m3u8
Please help me to solve this issue.
AVplay is throwing error(InvalidAccessError: PLAYER_ERROR_INVALID_OPERATION), if video URL is redirecting. Suppose video URL is https:abc.m3u8 and when try to play it, it redirects to https:xyz.m3u8
Please help me to solve this issue.
@tza1591371051 did you find a solution for this?
Please get final URL before passing to player. Looks like Samsung AVPlayer doesnât supports redirection on Media URL. I have faced same issue and fixed using below code.
function fetchRedirectedURL(originalURL) {
return fetch(originalURL, {method: âGETâ}).then((response) => {
if (response.status >= 200 && response.status <= 399) {
const redirectedURL = response.url;
if (redirectedURL) {
console.log(âfetchRedirectedURL - HTTP Status: â + response.status + â Use redirected MediaURL:â + redirectedURL);
return redirectedURL;
} else {
console.log(âfetchRedirectedURL - Empty URL - HTTP Status: â + response.status + â Use Original MediaURL:â + originalURL);
return originalURL; // if there is a empty URL in response return original URL
}
} else {
console.log(âfetchRedirectedURL - HTTP Status: â + response.status + â Use Original MediaURL:â + originalURL);
return originalURL; // if there is a network error (400+ or 500+) return original URL
}
}).catch((error) => {
this.logHelper.error(âDownloadManager::fetchRedirectedURL - Error resolving url,â + error);
console.log(âfetchRedirectedURL - Error: use original MediaURL:â + originalURL);
return originalURL; // safe check
});
}