gecko/dom/media/mediasource/test/test_FrameSelection.html

74 lines
2.3 KiB
HTML
Raw Normal View History

<!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();
var updateCount = 0;
runWithMSE(function (ms, v) {
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 () {
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");
fetchWithXHR("seek_lowres.webm", function (arrayBuffer) {
// Append initialization segment.
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
sb.addEventListener("updateend", function () {
updateCount++;
if (updateCount == 1) {
// Append media segment covering range [2, 4].
sb.appendBuffer(new Uint8Array(arrayBuffer, 51003));
}
else if (updateCount == 2) {
ms.endOfStream();
target = targets.shift();
v.currentTime = target.currentTime;
}
});
});
});
v.addEventListener("seeked", function () {
is(v.currentTime, target.currentTime, "Video currentTime at target");
is(v.videoWidth, target.videoWidth, "videoWidth has correct final value");
is(v.videoHeight, target.videoHeight, "videoHeight has correct final value");
target = targets.shift();
if (target) {
v.currentTime = target.currentTime;
} else {
SimpleTest.finish();
}
});
});
});
</script>
</pre>
</body>
</html>