diff --git a/assets/js/player.js b/assets/js/player.js index 649404b2..0556e1bb 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -57,6 +57,44 @@ var player; try { player = videojs('player', options); console.log('[Invidious Debug] videojs initialized successfully.'); + + // --- START WebOS DASH Workaround --- + var isWebOS = /Web[O0]S|LG Browser/i.test(navigator.userAgent); + console.log('[Invidious Debug] Checking for WebOS. User Agent:', navigator.userAgent, 'Is WebOS:', isWebOS); + + if (isWebOS && video_data.params.quality === 'dash') { + console.log('[Invidious Debug] WebOS detected with DASH quality. Attempting to filter sources.'); + // It might be too early here, sources might not be fully set. + // Let's try removing the source later, maybe on 'canplay' or 'sourceset' if needed. + // For now, just log the detection. We might need to hook into an event. + + // --- Alternative: Try filtering sources immediately (might not work) --- + try { + let currentSources = player.currentSources(); + console.log('[Invidious Debug] WebOS: Sources before filter:', JSON.stringify(currentSources)); + let filteredSources = currentSources.filter(function(source) { + return source.type !== 'application/dash+xml'; + }); + // Set filtered sources if different, find the non-DASH source + if (filteredSources.length > 0 && filteredSources.length < currentSources.length) { + console.log('[Invidious Debug] WebOS: Sources after filter:', JSON.stringify(filteredSources)); + // Select the first non-DASH source explicitly + let mp4Source = filteredSources.find(s => s.type.startsWith('video/mp4')); + if (mp4Source) { + console.log('[Invidious Debug] WebOS: Setting source explicitly to MP4:', JSON.stringify(mp4Source)); + player.src(mp4Source); // Try setting the source directly + } else { + console.warn('[Invidious Debug] WebOS: No suitable MP4 source found after filtering DASH.'); + } + } else { + console.log('[Invidious Debug] WebOS: No DASH source found to filter, or no other sources available.'); + } + } catch (e) { + console.error('[Invidious Debug] WebOS: Error filtering sources:', e); + } + } + // --- END WebOS DASH Workaround --- + } catch (e) { console.error('[Invidious Debug] videojs initialization FAILED:', e); // Stop further execution if player init fails @@ -104,7 +142,6 @@ player.on('error', function () { } }); -/* // Temporarily disabled for WebOS MP4 test - START if (video_data.params.quality === 'dash') { console.log('[Invidious Debug] Initializing reloadSourceOnError...'); try { @@ -116,7 +153,6 @@ if (video_data.params.quality === 'dash') { console.error('[Invidious Debug] reloadSourceOnError FAILED:', e); } } -*/ // Temporarily disabled for WebOS MP4 test - END /** * Function for add time argument to url @@ -312,7 +348,6 @@ if (video_data.params.autoplay) { }); } -/* // Temporarily disabled for WebOS MP4 test - START if (!video_data.params.listen && video_data.params.quality === 'dash') { console.log('[Invidious Debug] Initializing httpSourceSelector...'); console.log('[Invidious Debug] Player sources BEFORE httpSourceSelector init:', JSON.stringify(player.currentSources())); @@ -359,7 +394,6 @@ if (!video_data.params.listen && video_data.params.quality === 'dash') { console.error('[Invidious Debug] httpSourceSelector FAILED:', e); } } -*/ // Temporarily disabled for WebOS MP4 test - END console.log('[Invidious Debug] Initializing vttThumbnails...'); try {