Samsung Tizen TV AVplay is not playing video when video link is redirecting

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.

2 Likes

@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
});
}