-
Notifications
You must be signed in to change notification settings - Fork 54
/
test_WaitingOnMissingData_mp4.html
61 lines (58 loc) · 2.48 KB
/
test_WaitingOnMissingData_mp4.html
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
55
56
57
58
59
60
61
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<title>MSE: |waiting| event when source data is missing</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) => {
el.controls = true;
await once(ms, "sourceopen");
ok(true, "Receive a sourceopen event");
const audiosb = ms.addSourceBuffer("audio/mp4");
const videosb = ms.addSourceBuffer("video/mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s");
await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
await fetchAndLoad(videosb, "bipbop/bipbop_video", range(7, 14), ".m4s");
// HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM
// has notified it of available data. Make sure that we get "playing" before
// we starting waiting for "waiting".
info("Invoking play()");
let p = once(el, "playing");
el.play();
await p;
ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
p = once(el, "waiting");
el.play();
await p;
// currentTime is based on the current video frame, so if the audio ends just before
// the next video frame, currentTime can be up to 1 frame's worth earlier than
// min(audioEnd, videoEnd).
// 0.0465 is the length of the last audio frame.
ok(el.currentTime >= (Math.min(audiosb.buffered.end(0), videosb.buffered.end(0)) - 0.0465),
`Got a waiting event at ${el.currentTime}`);
info("Loading more data");
p = once(el, "ended");
await Promise.all([
fetchAndLoad(audiosb, "bipbop/bipbop_audio", [5], ".m4s"),
fetchAndLoad(videosb, "bipbop/bipbop_video", [6], ".m4s"),
]);
ms.endOfStream();
await p;
// These fuzz factors are bigger than they should be. We should investigate
// and fix them in bug 1137574.
isfuzzy(el.duration, 10.1, 0.1, "Video has correct duration: " + el.duration);
isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>