summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasource/test/test_SeekedEvent_mp4.html
blob: f80ae86f5abdec83c30289682184d88a67027b64 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE HTML>
<html>
<head>
  <title>MSE: Check that seeked event is fired prior loadeddata</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();

runWithMSE(function(ms, el) {
  el.controls = true;
  el._seeked = false;
  el._loadeddata = false;
  el._playing = false;
  el.addEventListener("seeked", function() {
    ok(true, "got seeked event");
    is(el._loadeddata, false, "can't have received loadeddata prior seeked");
    is(el._playing, false, "can't be playing prior seeked");
    el._seeked = true;
  });
  el.addEventListener("loadeddata", function() {
    ok(true, "got loadeddata event");
    is(el._seeked, true, "must have received seeked prior loadeddata");
    is(el._playing, false, "can't be playing prior playing");
    el._loadeddata = true;
  });
  el.addEventListener("playing", function() {
    ok(true, "got playing");
    is(el._seeked, true, "must have received seeked prior playing");
    is(el._loadeddata, true, "must have received loadeddata prior playing");
    el._playing = true;
  });
  once(ms, 'sourceopen').then(function() {
    ok(true, "Receive a sourceopen event");
    var videosb = ms.addSourceBuffer("video/mp4");
    is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
    fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
    .then(once.bind(null, el, "loadedmetadata"))
    .then(function() {
      el.play();
      videosb.timestampOffset = 2;
      is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
      // Load [2, 3.606).
      var promises = [];
      promises.push(once(el, "play"));
      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['1'], '.m4s'));
      return Promise.all(promises);
    })
    .then(function() {
      return fetchAndLoad(videosb, 'bipbop/bipbop_video', ['2'], '.m4s');
    })
    .then(function() {
      is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
      el.currentTime = 2;
      var promises = [];
      promises.push(once(el, "seeked"));
      promises.push(once(el, "playing"));
      return Promise.all(promises);
    })
    .then(function() {
      ok(true, "completed seek");
      SimpleTest.finish();
    });
  });
});

</script>
</pre>
</body>
</html>