2009-07-09 19:03:02 -07:00
|
|
|
function test_seek1(v, seekTime, is, ok, finish) {
|
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
var startPassed = false;
|
|
|
|
var endPassed = false;
|
|
|
|
var seekFlagStart = false;
|
|
|
|
var seekFlagEnd = false;
|
|
|
|
var readonly = true;
|
|
|
|
var completed = false;
|
|
|
|
|
|
|
|
function startTest() {
|
|
|
|
if (completed)
|
|
|
|
return false;
|
2009-01-05 17:18:40 -08:00
|
|
|
ok(!v.seeking, "seeking should default to false");
|
|
|
|
try {
|
2009-12-08 17:00:42 -08:00
|
|
|
v.seeking = true;
|
|
|
|
readonly = v.seeking === false;
|
2009-01-05 17:18:40 -08:00
|
|
|
}
|
|
|
|
catch(e) {
|
2009-12-08 17:00:42 -08:00
|
|
|
readonly = "threw exception: " + e;
|
2009-01-05 17:18:40 -08:00
|
|
|
}
|
2009-12-08 17:00:42 -08:00
|
|
|
is(readonly, true, "seeking should be readonly");
|
2009-01-05 17:18:40 -08:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
v.play();
|
2009-07-09 19:03:02 -07:00
|
|
|
v.currentTime=seekTime;
|
2009-02-19 09:23:13 -08:00
|
|
|
seekFlagStart = v.seeking;
|
2008-10-19 00:39:21 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function seekStarted() {
|
|
|
|
if (completed)
|
|
|
|
return false;
|
2011-07-11 20:39:32 -07:00
|
|
|
ok(v.currentTime >= seekTime - 0.1,
|
|
|
|
"Video currentTime should be around " + seekTime + ": " + v.currentTime + " (seeking)");
|
2008-12-15 20:58:33 -08:00
|
|
|
v.pause();
|
2008-10-19 00:39:21 -07:00
|
|
|
startPassed = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function seekEnded() {
|
|
|
|
if (completed)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var t = v.currentTime;
|
2009-05-17 17:25:05 -07:00
|
|
|
// Since we were playing, and we only paused asynchronously, we can't be
|
|
|
|
// sure that we paused before the seek finished, so we may have played
|
|
|
|
// ahead arbitrarily far.
|
2011-07-11 20:39:32 -07:00
|
|
|
ok(t >= seekTime - 0.1, "Video currentTime should be around " + seekTime + ": " + t + " (seeked)");
|
2008-12-15 20:58:33 -08:00
|
|
|
v.play();
|
2008-10-19 00:39:21 -07:00
|
|
|
endPassed = true;
|
|
|
|
seekFlagEnd = v.seeking;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function playbackEnded() {
|
|
|
|
if (completed)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
completed = true;
|
|
|
|
ok(startPassed, "seeking event");
|
|
|
|
ok(endPassed, "seeked event");
|
|
|
|
ok(seekFlagStart, "seeking flag on start should be true");
|
|
|
|
ok(!seekFlagEnd, "seeking flag on end should be false");
|
2009-07-09 19:03:02 -07:00
|
|
|
finish();
|
2008-10-19 00:39:21 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-09 19:03:02 -07:00
|
|
|
v.addEventListener("ended", playbackEnded, false);
|
|
|
|
v.addEventListener("loadedmetadata", startTest, false);
|
|
|
|
v.addEventListener("seeking", seekStarted, false);
|
|
|
|
v.addEventListener("seeked", seekEnded, false);
|
|
|
|
|
|
|
|
}
|