This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14309 - <track> Constructor for 'TextTrackCue' is not defined
Summary: <track> Constructor for 'TextTrackCue' is not defined
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
Whiteboard: K
Depends on:
Reported: 2011-09-27 17:09 UTC by Frank Olivier
Modified: 2012-07-18 18:39 UTC (History)
7 users (show)

See Also:


Description Frank Olivier 2011-09-27 17:09:30 UTC
Spec text:

In this example, an audio element is used to play a specific sound-effect from a sound file containing many sound effects. A cue is used to pause the audio, so that it ends exactly at the end of the clip, even if the browser is busy running some script. If the page had relied on script to pause the audio, then the start of the next clip might be heard if the browser was not able to run the script at the exact time specified.
var sfx = new Audio('sfx.wav');
var sounds = a.addTextTrack('metadata');

// add sounds we care about
sounds.addCue(new TextTrackCue('dog bark', 12.783, 13.612, '', '', '', true));
sounds.addCue(new TextTrackCue('kitten mew', 13.612, 15.091, '', '', '', true));

function playSound(id) {
  sfx.currentTime = sounds.getCueById(id).startTime;;

sfx.oncanplaythrough = function () {
  playSound('dog bark');
window.onbeforeunload = function () {
  playSound('kitten mew');
  return 'Are you sure you want to leave this awesome page?';

Issue description:

This example refers to a constructor, "new TextTrackCue" that is not defined anywhere in the spec.  In fact, the spec does not provide any way to create an instance of TextTrackCue without using a track element.
Comment 1 Ian 'Hixie' Hickson 2011-10-02 16:44:35 UTC
I'll add the constructor as part of taking all this out into the WebVTT CG.
Comment 2 Silvia Pfeiffer 2011-10-15 00:27:51 UTC
(In reply to comment #1)
> I'll add the constructor as part of taking all this out into the WebVTT CG.

Well, the HTML side of things wouldn't go into a WebVTT spec, right? So, the constructor still needs to go in there...
Comment 3 Frank Olivier 2011-10-28 18:54:04 UTC
As Sylvia points out, we need a constructor in the html spec.
Comment 4 Ian 'Hixie' Hickson 2011-10-28 19:50:13 UTC
And you have one now. That's why I marked the bug fixed.