I was working on the order that cues are displayed for a WebVTT file and I came across some interesting things. I was looking to test the following render rule which is a little hard to figure out but the HTML5 specification was very specific on the order.
"8. For each track track in tracks, append to cues all the cues from track's list of cues that have their text track cue active flag set."
http://dev.w3.org/html5/webvtt/#cues-with-video (April, 17, 2013)
This means that cues from different tracks should display the same as cues for the same track.
"13. Sort the tasks in events in ascending time order (tasks with earlier times first).
Further sort tasks in events that have the same time by the relative text track cue order of the text track cues associated with these tasks."
http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#list-of-newly-introduced-cues (April, 17, 2013)
The event time is the start time for entering cues, and later of the start and end time for exiting cues.
"text track cue order, which is determined as follows: first group the cues by their text track, with the groups being sorted in the same order as their text tracks appear in the media element's list of text tracks; then, within each group, cues must be sorted by their start time, earliest first; then, any cues with the same start time must be sorted by their end time, latest first; and finally, any cues with identical end times must be sorted in the order they were last added to their respective text track list of cues, oldest first"
http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#text-track-cue-order (April, 17, 2013)
Therefore the correct cue order is:
- start time (ascending)
- track order (top to bottom)
- end time (descending)
- cue order (top to bottom)
With the starting time being most important, one would think the ending time would be second. Instead the track order is second. This at first seems odd, but because the tracks are likely for different purposes, separating them is useful. Start time trumps track order because cues could appear in between other cues instead of at the top.
There are 12 reftests to test all possible cases with 1 track and 2 tracks.