HTML and CSS Reference
In-Depth Information
Listing I.13. Adjust the document
ready
event
Find the complete working example in the index-vtt-4a.html file.
Checking to see if the track is loaded
Text tracks have a ready state similar to other dynamically loadable objects (for example,
XMLHTTP requests). The complete list of values for text tracks is shown in
table I.5
.
Table I.5. Track
readyState
values
State
Value
Description
NONE
0
The track has not been loaded.
LOADING
1
The track is in the process of being loaded.
LOADED
2
The track has been loaded.
ERROR
3
Attempting to load the track led to an error.
Clearly, all you now need to do is check that the
readyState
of the track is
2
before you
attempt to access the
text
property. The next listing shows an updated
descriptions
case for the menu-handling function.
Listing I.14. Check the track ready state