125
When thecurrent playback positionp348
of amedia elementp333
changes (e.g. due to playback or seeking), the user agent must run thetime marches
onp356
steps. If thecurrent playback positionp348
changes while the steps are running, then the user agent must wait for the steps to complete, and
then must immediately rerun the steps. (These steps are thus run as often as possible or needed — if one iteration takes a long time, this can
cause certaincuesp366
to be skipped over as the user agent rushes ahead to "catch up".)
Thetime marches onsteps are as follows:
1. Letcurrent cuesbe a list ofcuesp366
, initialised to contain all thecuesp366
of all thehiddenp365
orshowingp365
text tracksp363
of themedia
elementp333
(not thedisabledp364
ones) whosestart timesp366
are less than or equal to thecurrent playback positionp348
and whoseend
timesp366
are greater than thecurrent playback positionp348
.
2. Letother cuesbe a list ofcuesp366
, initialised to contain all thecuesp366
ofhiddenp365
andshowingp365
text tracksp363
of themedia
elementp333
that are not present incurrent cues.
3. Letlast timebe thecurrent playback positionp348
at the time this algorithm was last run for thismedia elementp333
, if this is not the first
time it has run.
4. If thecurrent playback positionp348
has, since the last time this algorithm was run, only changed through its usual monotonic increase
during normal playback, then letmissed cuesbe the list ofcuesp366
inother cueswhosestart timesp366
are greater than or equal tolast
timeand whoseend timesp366
are less than or equal to thecurrent playback positionp348
. Otherwise, letmissed cuesbe an empty list.
5. Remove all thecuesp366
inmissed cuesthat are also in themedia elementp333
'slist of newly introduced cuesp355
, and then empty the
element'slist of newly introduced cuesp355
.
6. If the time was reached through the usual monotonic increase of thecurrent playback positionp348
during normal playback, and if the
user agent has not fired atimeupdatep384
event at the element in the past 15 to 250ms and is not still running event handlers for such
an event, then the user agent mustqueue a taskp843
tofire a simple eventp854
namedtimeupdatep384
at the element. (In the other
cases, such as explicit seeks, relevant events get fired as part of the overall process of changing thecurrent playback positionp348
.)
7. If all of thecuesp366
incurrent cueshave theirtext track cue active flagp366
set, none of thecuesp366
inother cueshave theirtext track
cue active flagp366
set, andmissed cuesis empty, then abort these steps.
8. If the time was reached through the usual monotonic increase of thecurrent playback positionp348
during normal playback, and there are
cuesp366
inother cuesthat have theirtext track cue pause-on-exit flagp366
set and that either have theirtext track cue active flagp366
set
or are also inmissed cues, thenimmediatelyp42
pausep354
themedia elementp333
.
9. Leteventsbe a list oftasksp842
, initially empty. Eachtaskp842
in this list will be associated with atext trackp363
, atext track cuep366
, and a
time, which are used to sort the list before thetasksp842
are queued.
Letaffected tracksbe a list oftext tracksp363
, initially empty.
When the steps below say toprepare an eventnamedeventfor atext track cuep366
targetwith a timetime, the user agent must run
these substeps:
1. Lettrackbe thetext trackp363
with which thetext track cuep366
targetis associated.
2. Create ataskp842
tofire a simple eventp854
namedeventattarget.
3. Add the newly createdtaskp842
toevents, associated with the timetime, thetext trackp363
track, and thetext track cuep366
target.
4. Addtracktoaffected tracks.
10. For eachtext track cuep366
inmissed cues,prepare an eventp356
namedenterp384
for theTextTrackCuep375
object with thetext track
cue start timep366
.
11. For eachtext track cuep366
inother cuesthat either has itstext track cue active flagp366
set or is inmissed cues,prepare an eventp356
namedexitp384
for theTextTrackCuep375
object with the later of thetext track cue end timep366
and thetext track cue start timep366
.
The event thus is not to be fired faster than about 66Hz or slower than 4Hz (assuming the event handlers don't take longer than
250ms to run). User agents are encouraged to vary the frequency of the event based on the system load and the average cost
of processing the event each time, so that the UI updates are not any more frequent than the user agent can comfortably
handle while decoding the video.
Note
In the other cases, such as explicit seeks, playback is not paused by going past the end time of acuep366
, even if thatcuep366
has itstext track cue pause-on-exit flagp366
set.
Note
356