1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: seeking to end of data with data gap.</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">
SimpleTest.waitForExplicitFinish();
runWithMSE(async (ms, el) => {
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
const videosb = ms.addSourceBuffer("video/mp4");
const audiosb = ms.addSourceBuffer("audio/mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
is(videosb.buffered.length, 1, "continuous buffered range");
// Ensure we have at least 2s less audio than video.
audiosb.appendWindowEnd = videosb.buffered.end(0) - 2;
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 6), ".m4s");
ms.endOfStream();
await Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
ok(true, "endOfStream completed");
// Seek to the middle of the gap where audio is missing. As we are in readyState = ended
// seeking must complete.
el.currentTime = videosb.buffered.end(0) / 2 + audiosb.buffered.end(0) / 2;
ok(el.currentTime - audiosb.buffered.end(0) >= 1, "gap is big enough");
is(el.buffered.length, 1, "continuous buffered range");
is(el.buffered.end(0), videosb.buffered.end(0),
"buffered range end is aligned with longest track");
ok(el.seeking, "element is now seeking");
ok(el.currentTime >= el.buffered.start(0) && el.currentTime <= el.buffered.end(0),
"seeking time is in buffered range");
ok(el.currentTime > audiosb.buffered.end(0),
"seeking point is not buffered in audio track");
await once(el, "seeked");
ok(true, "we have successfully seeked");
// Now ensure that we can play to the end, even though we are missing data in one track.
el.play();
await once(el, "ended");
SimpleTest.finish(SimpleTest);
});
</script>
</pre>
</body>
</html>
|