Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[e] (0) Fix an example to use the new API.
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=16076
Affected topics: Video Text Tracks

git-svn-id: http://svn.whatwg.org/webapps@7331 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Sep 11, 2012
1 parent c810712 commit 9a1e20a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions complete.html
Expand Up @@ -34977,17 +34977,25 @@ <h6 id=text-track-api><span class=secno>4.8.10.12.5 </span>Text track API</h6>
var sounds = sfx.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 addFX(start, end, name) {
var cue = new TextTrackCue(start, end, '');
cue.id = name;
cue.pauseOnExit = true;
sounds.addCue(cue);
}
addFX(12.783, 13.612, 'dog bark');
addFX(13.612, 15.091, 'kitten mew'))

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

// play a bark as soon as we can
sfx.oncanplaythrough = function () {
playSound('dog bark');
}
// meow when the user tries to leave
window.onbeforeunload = function () {
playSound('kitten mew');
return 'Are you sure you want to leave this awesome page?';
Expand Down
12 changes: 10 additions & 2 deletions index
Expand Up @@ -34977,17 +34977,25 @@ interface <dfn id=texttrack>TextTrack</dfn> : <a href=#eventtarget>EventTarget</
var sounds = sfx.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 addFX(start, end, name) {
var cue = new TextTrackCue(start, end, '');
cue.id = name;
cue.pauseOnExit = true;
sounds.addCue(cue);
}
addFX(12.783, 13.612, 'dog bark');
addFX(13.612, 15.091, 'kitten mew'))

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

// play a bark as soon as we can
sfx.oncanplaythrough = function () {
playSound('dog bark');
}
// meow when the user tries to leave
window.onbeforeunload = function () {
playSound('kitten mew');
return 'Are you sure you want to leave this awesome page?';
Expand Down
12 changes: 10 additions & 2 deletions source
Expand Up @@ -38361,17 +38361,25 @@ interface <dfn>TextTrack</dfn> : <span>EventTarget</span> {
var sounds = sfx.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 addFX(start, end, name) {
var cue = new TextTrackCue(start, end, '');
cue.id = name;
cue.pauseOnExit = true;
sounds.addCue(cue);
}
addFX(12.783, 13.612, 'dog bark');
addFX(13.612, 15.091, 'kitten mew'))

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

// play a bark as soon as we can
sfx.oncanplaythrough = function () {
playSound('dog bark');
}
// meow when the user tries to leave
window.onbeforeunload = function () {
playSound('kitten mew');
return 'Are you sure you want to leave this awesome page?';
Expand Down

0 comments on commit 9a1e20a

Please sign in to comment.