Update TrailerPlayer.tsx

This commit is contained in:
CK 2026-03-05 13:54:56 +05:30 committed by GitHub
parent b2cce94841
commit 2019230dfd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -374,12 +374,20 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
<Video
ref={videoRef}
source={(() => {
const androidHeaders = Platform.OS === 'android' ? { 'User-Agent': 'Nuvio/1.0 (Android)' } : {} as any;
const lower = (trailerUrl || '').toLowerCase();
const looksLikeHls = /\.m3u8(\b|$)/.test(lower) || /hls|applehlsencryption|playlist|m3u/.test(lower);
// Detect both .mpd URLs and inline data: DASH manifests
const looksLikeDash = /\.mpd(\b|$)/.test(lower) || /dash|manifest/.test(lower) || lower.startsWith('data:application/dash');
if (Platform.OS === 'android') {
// For DASH streams from YouTube (googlevideo.com CDN), use the same
// User-Agent as the ANDROID_VR Innertube client used during extraction.
// For all other URLs (HLS, MP4 from server fallback) use a generic UA.
const isYouTubeCdn = lower.includes('googlevideo.com') || lower.includes('youtube.com');
const androidHeaders = {
'User-Agent': (looksLikeDash && isYouTubeCdn)
? 'com.google.android.apps.youtube.vr.oculus/1.60.19 (Linux; U; Android 12L; eureka-user Build/SQ3A.220605.009.A1) gzip'
: 'Nuvio/1.0 (Android)',
};
if (looksLikeHls) {
return { uri: trailerUrl, type: 'm3u8', headers: androidHeaders } as any;
}