summaryrefslogtreecommitdiffstats
path: root/dom/media/autoplay/test/browser/file_mediaplayback_frame.html
blob: b5685c07b375f45fcae6a857022a6a898c3bec9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>
<head>
<title>Non-Autoplay page being used in Iframe</title>
</head>
<body>
<video id="video" src="gizmo.mp4" loop></video>
<script type="text/javascript">

const video = document.getElementById("video");
const w = window.opener || window.parent;

window.onmessage = async event => {
  if (event.data == "play") {
    let rv = await video.play().then(() => true, () => false);
    w.postMessage(rv ? "played" : "blocked", "*");
  }
}
</script>
</body>
</html>