2014-09-04 23:20:23 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>MSE: verify correct frames selected for given position</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="mediasource.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2014-11-18 20:16:41 -08:00
|
|
|
var updateCount = 0;
|
|
|
|
|
2014-09-11 21:34:38 -07:00
|
|
|
runWithMSE(function (ms, v) {
|
2014-09-04 23:20:23 -07:00
|
|
|
ms.addEventListener("sourceopen", function () {
|
|
|
|
var sb = ms.addSourceBuffer("video/webm");
|
|
|
|
|
|
|
|
fetchWithXHR("seek.webm", function (arrayBuffer) {
|
|
|
|
// Append entire file covering range [0, 4].
|
|
|
|
sb.appendBuffer(new Uint8Array(arrayBuffer));
|
|
|
|
});
|
|
|
|
|
|
|
|
var targets = [{ currentTime: 3, videoWidth: 160, videoHeight: 120 },
|
|
|
|
{ currentTime: 2, videoWidth: 160, videoHeight: 120 },
|
|
|
|
{ currentTime: 0, videoWidth: 320, videoHeight: 240 }];
|
|
|
|
var target;
|
|
|
|
|
|
|
|
v.addEventListener("loadedmetadata", function () {
|
2014-10-01 22:04:06 -07:00
|
|
|
is(v.currentTime, 0, "currentTime has correct initial value");
|
|
|
|
is(v.videoWidth, 320, "videoWidth has correct initial value");
|
|
|
|
is(v.videoHeight, 240, "videoHeight has correct initial value");
|
2014-09-04 23:20:23 -07:00
|
|
|
|
|
|
|
fetchWithXHR("seek_lowres.webm", function (arrayBuffer) {
|
|
|
|
// Append initialization segment.
|
|
|
|
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
|
2014-09-08 15:29:41 -07:00
|
|
|
sb.addEventListener("updateend", function () {
|
2014-11-18 20:16:41 -08:00
|
|
|
updateCount++;
|
|
|
|
if (updateCount == 1) {
|
2014-09-08 15:29:41 -07:00
|
|
|
// Append media segment covering range [2, 4].
|
|
|
|
sb.appendBuffer(new Uint8Array(arrayBuffer, 51003));
|
2014-11-18 20:16:41 -08:00
|
|
|
}
|
|
|
|
else if (updateCount == 2) {
|
2014-09-08 15:29:41 -07:00
|
|
|
ms.endOfStream();
|
2014-09-14 21:16:54 -07:00
|
|
|
target = targets.shift();
|
|
|
|
v.currentTime = target.currentTime;
|
2014-09-08 15:29:41 -07:00
|
|
|
}
|
|
|
|
});
|
2014-09-04 23:20:23 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
v.addEventListener("seeked", function () {
|
2014-10-01 22:04:06 -07:00
|
|
|
is(v.currentTime, target.currentTime, "Video currentTime at target");
|
2014-09-04 23:20:23 -07:00
|
|
|
|
2014-10-01 22:04:06 -07:00
|
|
|
is(v.videoWidth, target.videoWidth, "videoWidth has correct final value");
|
|
|
|
is(v.videoHeight, target.videoHeight, "videoHeight has correct final value");
|
2014-09-04 23:20:23 -07:00
|
|
|
|
|
|
|
target = targets.shift();
|
|
|
|
if (target) {
|
|
|
|
v.currentTime = target.currentTime;
|
|
|
|
} else {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|