Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>MSE: Playback must not stall when buffer starts at a non-zero timestamp</title>
<script 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">
// When an HLS/MSE stream's buffer starts at a non-zero timestamp, MDSM's
// BufferingState must request video data at the current media time, not at time=0.
SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, v) => {
await once(ms, "sourceopen");
const audiosb = ms.addSourceBuffer("audio/mp4");
const videosb = ms.addSourceBuffer("video/mp4");
// Shift all segment timestamps by 8 seconds, simulating an HLS stream whose
// first segment starts at t=8 in the media timeline.
const kBufferStart = 8;
audiosb.timestampOffset = kBufferStart;
videosb.timestampOffset = kBufferStart;
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["1"], ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["1"], ".m4s");
// Buffered range is now [~8, ~9] for both tracks.
info(`Audio buffered: ${timeRangeToString(audiosb.buffered)}`);
info(`Video buffered: ${timeRangeToString(videosb.buffered)}`);
// Seek to the start of the buffered region.
v.currentTime = kBufferStart;
ok(await v.play().then(_ => true, _ => false), "video started playing");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>