|
23 | 23 | * Apply translations to all media players |
24 | 24 | */ |
25 | 25 | function vidstackApplyTranslations() { |
| 26 | + console.log('Vidstack: Applying translations...'); |
26 | 27 | ['media-video-layout', 'media-audio-layout'].forEach(selector => { |
27 | | - document.querySelectorAll(selector).forEach(layout => { |
| 28 | + const layouts = document.querySelectorAll(selector); |
| 29 | + console.log('Vidstack: Found', layouts.length, selector, 'elements'); |
| 30 | + layouts.forEach(layout => { |
28 | 31 | const player = layout.closest('media-player'); |
29 | 32 | const lang = player?.getAttribute('lang') || document.documentElement.lang || 'en'; |
30 | 33 |
|
|
55 | 58 | * Main initialization function |
56 | 59 | */ |
57 | 60 | async function vidstackInitialize() { |
| 61 | + console.log('Vidstack: Starting initialization...'); |
58 | 62 | await vidstackLoadTranslations(); |
| 63 | + console.log('Vidstack: Translations loaded, found', Object.keys(vidstackTranslations).length, 'languages'); |
59 | 64 | vidstackInitializeMediaPlayers(); |
60 | 65 |
|
61 | 66 | // Watch for dynamically added players (AJAX, etc.) |
|
103 | 108 | // If DOM is already ready or script loads late (e.g., with defer), initialize immediately |
104 | 109 | if (document.readyState === 'complete' || |
105 | 110 | (document.readyState === 'interactive' && document.body)) { |
| 111 | + console.log('Vidstack: Initializing immediately (readyState:', document.readyState + ')'); |
106 | 112 | vidstackInitialize(); |
| 113 | + } else { |
| 114 | + console.log('Vidstack: Waiting for DOM (readyState:', document.readyState + ')'); |
107 | 115 | } |
108 | 116 | })(); |
0 commit comments