2009-07-10 02:03:02 +00:00
|
|
|
function test_seek1(v, seekTime, is, ok, finish) {
|
|
|
|
|
2008-10-19 07:39:21 +00: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-06 01:18:40 +00:00
|
|
|
ok(!v.seeking, "seeking should default to false");
|
|
|
|
try {
|
2009-12-09 01:00:42 +00:00
|
|
|
v.seeking = true;
|
|
|
|
readonly = v.seeking === false;
|
2009-01-06 01:18:40 +00:00
|
|
|
}
|
|
|
|
catch(e) {
|
2009-12-09 01:00:42 +00:00
|
|
|
readonly = "threw exception: " + e;
|
2009-01-06 01:18:40 +00:00
|
|
|
}
|
2009-12-09 01:00:42 +00:00
|
|
|
is(readonly, true, "seeking should be readonly");
|
2009-01-06 01:18:40 +00:00
|
|
|
|
2008-10-19 07:39:21 +00:00
|
|
|
v.play();
|
2009-07-10 02:03:02 +00:00
|
|
|
v.currentTime=seekTime;
|
2009-02-19 17:23:13 +00:00
|
|
|
seekFlagStart = v.seeking;
|
2008-10-19 07:39:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function seekStarted() {
|
|
|
|
if (completed)
|
|
|
|
return false;
|
2008-12-16 04:58:33 +00:00
|
|
|
v.pause();
|
2008-10-19 07:39:21 +00:00
|
|
|
startPassed = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function seekEnded() {
|
|
|
|
if (completed)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var t = v.currentTime;
|
2009-05-18 00:25:05 +00: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.
|
2009-07-10 02:03:02 +00:00
|
|
|
ok(t >= seekTime - 0.1, "Video currentTime should be around " + seekTime + ": " + t);
|
2008-12-16 04:58:33 +00:00
|
|
|
v.play();
|
2008-10-19 07:39:21 +00: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-10 02:03:02 +00:00
|
|
|
finish();
|
2008-10-19 07:39:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-10 02:03:02 +00:00
|
|
|
v.addEventListener("ended", playbackEnded, false);
|
|
|
|
v.addEventListener("loadedmetadata", startTest, false);
|
|
|
|
v.addEventListener("seeking", seekStarted, false);
|
|
|
|
v.addEventListener("seeked", seekEnded, false);
|
|
|
|
|
|
|
|
}
|