Skip to content

Commit d39a548

Browse files
committed
moving backdrop example from Glitch
1 parent 015c44c commit d39a548

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

backdrop/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>MDN Web Docs Example: Toggling full-screen mode</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
8+
<!-- import the webpage's stylesheet -->
9+
<link rel="stylesheet" href="style.css">
10+
11+
<!-- import the webpage's javascript file -->
12+
<script src="script.js" defer></script>
13+
</head>
14+
<body>
15+
<h1>Example: Toggling full-screen presentation of a video</h1>
16+
17+
<p>In this example, we see a video element showing a movie ("Big Buck Bunny").
18+
you can toggle full screen mode on and off by pressing the Return or Enter key.</p>
19+
20+
<!-- Simple video example -->
21+
<!-- 'Big Buck Bunny' licensed under CC 3.0 by the Blender foundation. Hosted by archive.org -->
22+
<!-- Poster from peach.blender.org -->
23+
<video controls
24+
src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
25+
poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
26+
width="620">
27+
28+
Sorry, your browser doesn't support embedded videos. Time to upgrade!
29+
30+
</video>
31+
</body>
32+
</html>

backdrop/script.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Any copyright is dedicated to the Public Domain.
2+
// http://creativecommons.org/publicdomain/zero/1.0/
3+
4+
window.addEventListener("load", doStartup, false);
5+
6+
function doStartup(event) {
7+
document.fullscreenElement = document.fullscreenElement || document.mozFullscreenElement
8+
|| document.msFullscreenElement || document.webkitFullscreenDocument;
9+
document.exitFullscreen = document.exitFullscreen || document.mozExitFullscreen
10+
|| document.msExitFullscreen || document.webkitExitFullscreen;
11+
12+
document.addEventListener("keypress", handleKeypress, false);
13+
}
14+
15+
function handleKeypress(event) {
16+
if (event.keyCode === 13) {
17+
toggleFullscreen();
18+
}
19+
}
20+
21+
22+
function toggleFullscreen() {
23+
let elem = document.querySelector("video");
24+
25+
elem.requestFullscreen = elem.requestFullscreen || elem.mozRequestFullscreen
26+
|| elem.msRequestFullscreen || elem.webkitRequestFullscreen;
27+
28+
if (!document.fullscreenElement) {
29+
elem.requestFullscreen().then({}).catch(err => {
30+
alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
31+
});
32+
} else {
33+
if (document.exitFullscreen) {
34+
document.exitFullscreen();
35+
}
36+
}
37+
}

backdrop/style.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* CSS files add styling rules to your content */
2+
3+
body {
4+
font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
5+
margin: 2em;
6+
}
7+
8+
h1 {
9+
font-style: italic;
10+
color: #373fff;
11+
}
12+
13+
video::backdrop {
14+
background-color: #448;
15+
}

0 commit comments

Comments
 (0)