mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Backed out changeset 9ca7e64ef0d0 (bug 921484)
This commit is contained in:
parent
7f84d88bf6
commit
2f2426fd1c
@ -148,27 +148,28 @@ TextTrack::GetActiveCues()
|
||||
// the active cue list from scratch.
|
||||
if (mDirty) {
|
||||
mCuePos = 0;
|
||||
mDirty = false;
|
||||
mDirty = true;
|
||||
mActiveCueList->RemoveAll();
|
||||
}
|
||||
|
||||
double playbackTime = mMediaElement->CurrentTime();
|
||||
// Remove all the cues from the active cue list whose end times now occur
|
||||
// earlier then the current playback time.
|
||||
for (uint32_t i = mActiveCueList->Length(); i > 0; i--) {
|
||||
if ((*mActiveCueList)[i - 1]->EndTime() < playbackTime) {
|
||||
mActiveCueList->RemoveCueAt(i - 1);
|
||||
}
|
||||
// earlier then the current playback time. When we reach a cue whose end time
|
||||
// is valid we can safely stop iterating as the list is sorted.
|
||||
for (uint32_t i = 0; i < mActiveCueList->Length() &&
|
||||
(*mActiveCueList)[i]->EndTime() < playbackTime; i++) {
|
||||
mActiveCueList->RemoveCueAt(i);
|
||||
}
|
||||
// Add all the cues, starting from the position of the last cue that was
|
||||
// added, that have valid start and end times for the current playback time.
|
||||
// We can stop iterating safely once we encounter a cue that does not have
|
||||
// a valid start time as the cue list is sorted.
|
||||
for (; mCuePos < mCueList->Length() &&
|
||||
(*mCueList)[mCuePos]->StartTime() <= playbackTime; mCuePos++) {
|
||||
if ((*mCueList)[mCuePos]->EndTime() >= playbackTime) {
|
||||
mActiveCueList->AddCue(*(*mCueList)[mCuePos]);
|
||||
// valid times for the current playback time as the cue list is sorted.
|
||||
for (; mCuePos < mCueList->Length(); mCuePos++) {
|
||||
TextTrackCue* cue = (*mCueList)[mCuePos];
|
||||
if (cue->StartTime() > playbackTime || cue->EndTime() < playbackTime) {
|
||||
break;
|
||||
}
|
||||
mActiveCueList->AddCue(*cue);
|
||||
}
|
||||
return mActiveCueList;
|
||||
}
|
||||
|
@ -8,18 +8,10 @@ This
|
||||
00:01.200 --> 00:02.400
|
||||
Is
|
||||
|
||||
2.5
|
||||
00:02.000 --> 00:03.500
|
||||
(Over here?!)
|
||||
|
||||
3
|
||||
00:02.710 --> 00:02.910
|
||||
A
|
||||
|
||||
4
|
||||
3
|
||||
00:03.217 --> 00:03.989
|
||||
Test
|
||||
|
||||
5
|
||||
00:03.217 --> 00:03.989
|
||||
And more!
|
||||
Test
|
@ -37,7 +37,7 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
||||
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
|
||||
|
||||
var cueList = trackElement.track.cues;
|
||||
is(cueList.length, 6, "Cue list length should be 6.");
|
||||
is(cueList.length, 4, "Cue list length should be 4.");
|
||||
|
||||
// Check that the typedef of TextTrackCue works in Gecko.
|
||||
is(window.TextTrackCue, undefined, "TextTrackCue should be undefined.");
|
||||
@ -57,22 +57,18 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
||||
// Check that all cue times were not rounded
|
||||
is(cueList[1].startTime, 1.2, "Second cue's start time should be 1.2.");
|
||||
is(cueList[1].endTime, 2.4, "Second cue's end time should be 2.4.");
|
||||
is(cueList[2].startTime, 2, "Third cue's start time should be 2.");
|
||||
is(cueList[2].endTime, 3.5, "Third cue's end time should be 3.5.");
|
||||
is(cueList[3].startTime, 2.71, "Fourth cue's start time should be 2.71.");
|
||||
is(cueList[3].endTime, 2.91, "Fourth cue's end time should be 2.91.");
|
||||
is(cueList[4].startTime, 3.217, "Fifth cue's start time should be 3.217.");
|
||||
is(cueList[4].endTime, 3.989, "Fifth cue's end time should be 3.989.");
|
||||
is(cueList[5].startTime, 3.217, "Sixth cue's start time should be 3.217.");
|
||||
is(cueList[5].endTime, 3.989, "Sixth cue's end time should be 3.989.");
|
||||
is(cueList[2].startTime, 2.71, "Third cue's start time should be 2.71.");
|
||||
is(cueList[2].endTime, 2.91, "Third cue's end time should be 2.91.");
|
||||
is(cueList[3].startTime, 3.217, "Fourth cue's start time should be 3.217.");
|
||||
is(cueList[3].endTime, 3.989, "Fourth cue's end time should be 3.989.");
|
||||
|
||||
// Check that Cue setters are working correctly.
|
||||
cue.id = "Cue 01";
|
||||
is(cue.id, "Cue 01", "Cue's ID should be 'Cue 01'.");
|
||||
cue.startTime = 0.51;
|
||||
is(cue.startTime, 0.51, "Cue's start time should be 0.51.");
|
||||
cue.endTime = 0.71;
|
||||
is(cue.endTime, 0.71, "Cue's end time should be 0.71.");
|
||||
cue.startTime = 1.5;
|
||||
is(cue.startTime, 1.5, "Cue's start time should be 1.5.");
|
||||
cue.endTime = 2.5;
|
||||
is(cue.endTime, 2.5, "Cue's end time should be 2.5.");
|
||||
cue.pauseOnExit = true;
|
||||
is(cue.pauseOnExit, true, "Cue's pause on exit flag should be true.");
|
||||
|
||||
@ -114,21 +110,21 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
||||
// Check that we can create and add new VTTCues
|
||||
var vttCue = new VTTCue(3.999, 4, "foo");
|
||||
trackElement.track.addCue(vttCue);
|
||||
is(cueList.length, 7, "Cue list length should now be 7.");
|
||||
is(cueList.length, 5, "Cue list length should now be 5.");
|
||||
|
||||
// Check that new VTTCue was added correctly
|
||||
cue = cueList[6];
|
||||
cue = cueList[4];
|
||||
is(cue.startTime, 3.999, "Cue's start time should be 3.999.");
|
||||
is(cue.endTime, 4, "Cue's end time should be 4.");
|
||||
is(cue.text, "foo", "Cue's text should be foo.");
|
||||
|
||||
// Adding the same cue again should not increase the cue count.
|
||||
trackElement.track.addCue(vttCue);
|
||||
is(cueList.length, 7, "Cue list length should be 7.");
|
||||
is(cueList.length, 5, "Cue list length should be 5.");
|
||||
|
||||
// Check that we are able to remove cues.
|
||||
trackElement.track.removeCue(cue);
|
||||
is(cueList.length, 6, "Cue list length should be 6.");
|
||||
is(cueList.length, 4, "Cue list length should be 4.");
|
||||
|
||||
exceptionHappened = false;
|
||||
try {
|
||||
@ -145,45 +141,9 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
||||
// when we shouln't have.
|
||||
ok(exceptionHappened, "Exception should have happened.");
|
||||
|
||||
is(cueList.length, 6, "Cue list length should be 6.");
|
||||
is(cueList.length, 4, "Cue list length should be 4.");
|
||||
|
||||
// Test TextTrack::ActiveCues.
|
||||
var cueInfo = [
|
||||
{ startTime: 0.51, endTime: 0.71, ids: ["Cue 01"] },
|
||||
{ startTime: 1.2, endTime: 2, ids: [2] },
|
||||
{ startTime: 2, endTime: 2.4, ids: [2, 2.5] },
|
||||
{ startTime: 2.4, endTime: 2.71, ids: [2.5] },
|
||||
{ startTime: 2.71, endTime: 2.91, ids: [2.5, 3] },
|
||||
{ startTime: 2.91, endTime: 3.217, ids: [2.5] },
|
||||
{ startTime: 3.217, endTime: 3.5, ids: [2.5, 4, 5] },
|
||||
{ startTime: 3.50, endTime: 3.989, ids: [4, 5] }
|
||||
];
|
||||
|
||||
video.addEventListener("timeupdate", function() {
|
||||
var activeCues = trackElement.track.activeCues,
|
||||
found = false,
|
||||
playbackTime = video.currentTime;
|
||||
|
||||
for (var i = 0; i < cueInfo.length && !found; i++) {
|
||||
var cue = cueInfo[i];
|
||||
if (playbackTime >= cue.startTime && playbackTime <= cue.endTime) {
|
||||
is(activeCues.length, cue.ids.length, "There should be " + cue.ids.length + " currently active cue(s).");
|
||||
for (var j = 0; j < cue.ids.length; j++) {
|
||||
isnot(activeCues.getCueById(cue.ids[j]), undefined, "The cue with ID " + cue.ids[j] + " should be active.");
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
is(activeCues.length, 0, "There should be 0 currently active cues.");
|
||||
}
|
||||
});
|
||||
|
||||
video.addEventListener("ended", function(){
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
video.play();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user