mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
69 lines
2.8 KiB
HTML
69 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html><head>
|
|
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
|
|
<title>MSE: Don't get stuck buffering for too long when we have frames to show</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 receivedSourceOpen = false;
|
|
runWithMSE(function(ms, v) {
|
|
ms.addEventListener("sourceopen", function() {
|
|
ok(true, "Receive a sourceopen event");
|
|
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
|
|
receivedSourceOpen = true;
|
|
var sb = ms.addSourceBuffer("video/webm");
|
|
ok(sb, "Create a SourceBuffer");
|
|
|
|
function waitUntilTime(targetTime) {
|
|
return new Promise(function(resolve, reject) {
|
|
v.addEventListener("waiting", function onwaiting() {
|
|
info("Got a waiting event at " + v.currentTime);
|
|
if (v.currentTime >= targetTime) {
|
|
ok(true, "Reached target time of: " + targetTime);
|
|
v.removeEventListener("waiting", onwaiting);
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
fetchWithXHR("seek.webm", function(arrayBuffer) {
|
|
sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
|
|
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))().then(
|
|
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25223-318))).then(
|
|
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25223, 46712-25223))).then(
|
|
/* Note - Missing |46712, 67833 - 46712| segment here corresponding to (0.8, 1.2] */
|
|
/* Note - Missing |67833, 88966 - 67833| segment here corresponding to (1.2, 1.6] */
|
|
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966))).then(function() {
|
|
var promise = waitUntilTime(0.7);
|
|
info("Playing video. It should play for a bit, then fire 'waiting'");
|
|
v.play();
|
|
return promise;
|
|
}).then(function() {
|
|
window.firstStop = Date.now();
|
|
loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
|
|
return waitUntilTime(1.0);
|
|
}).then(function() {
|
|
var waitDuration = (Date.now() - window.firstStop) / 1000;
|
|
ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
|
|
SimpleTest.finish();
|
|
/* If we allow the rest of the stream to be played, we get stuck at
|
|
around 2s. See bug 1093133.
|
|
once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
|
|
return loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
|
|
*/
|
|
});
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|