Firefox and Chromium browsers. Video tag and embedded track
Each TextTrack object has a cues property, which is a TextTrackCueList containing VTTCue objects (all labels of the current track).
Each VTTCue object has a track property, which is a TextTrack object. This TextTrack - see the first item.
If you imagine a tree
TextTrack cues[0] track cues[0] track ... и так до неопределенной глубины. HTML
<video width="400" height="225" id="myVideo" preload="metadata" controls> <source src="my-video.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> <track src="track.vtt" default="true" kind="subtitles" srclang="en" label="English"> </video> You can open the developer tools in the browser, or go through the script in the depth of the tree.
Javascript
<script> var headTrack; // После загрузки окна получаем объект трека // Навешиваем на него обработчик window.onload = function() { var headTrack = myVideo.textTracks[0]; headTrack.addEventListener('cuechange', getAllTracks); console.log(myVideo.textTracks); }; // Когда браузер заходит в метку, запускаем основную функцию function getAllTracks(event) { var currentTrack = event.target; getHoleTracks(currentTrack); } // Счётчик, чтобы не было бесконечной рекурсии var counter = 0; // Извлекаем cues из textTrack // Извлекаем track из VTTCue function getHoleTracks(textTrack) { counter++; var firstCue = textTrack.cues[0]; var cuesTrack = firstCue.track; // Вывод в консоль для наглядности console.log(counter); console.log('firstCue' + firstCue); console.log('cuesTrack' + cuesTrack); // Если последний TextTrack содержит cues, повторяем // Ограничимся сотней выводов if (cuesTrack.cues[0] && (counter < 100) ) { getHoleTracks(cuesTrack); } } </script> Questions
Is that a rabbit hole without a bottom? Bug or feature?
Does the browser load affect such a tree of objects or does it somehow optimize without creating it to the full depth?
Or am I misreading something?


