-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfullscreen.html
162 lines (128 loc) · 4.49 KB
/
fullscreen.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE HTML>
<!--
this file is from https://github.com/nickshin/CheatSheets/
this file contains some HTML5 snippets on:
- fullscreen API
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
reference sources:
+ http://updates.html5rocks.com/2011/10/Let-Your-Content-Do-the-Talking-Fullscreen-API
DEMO!!!
+ http://html5-demos.appspot.com/static/fullscreen.html
notes:
- this is basically a copy of the DEMO above...
+ some browsers NEED to have FULLSCREEN API ENABLED MANUALLY
o https://developer.mozilla.org/en/DOM/Using_full-screen_mode#Gecko_notes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
best viewed in editor with tab stops set to 4
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-->
<!-- ================================================== -->
<!-- START OF HTML -->
<html>
<head>
<title>Fullscreen : HTML5 test code</title>
<!-- ================================================== -->
<!-- Cascade Style Sheets {{{ -->
<!-- ================================================== -->
<style>
div:-webkit-full-screen {
width: 100% !important;
}
div:-moz-full-screen {
width: 100% !important;
}
:-webkit-full-screen .tohide {
display: none; /* While in fullscreen, hide any children with class 'tohide' */
}
:-moz-full-screen .tohide {
display: none; /* While in fullscreen, hide any children with class 'tohide' */
}
</style>
<!-- ================================================== -->
<!-- Cascade Style Sheets }}} -->
<!-- Javascript {{{ -->
<!-- ================================================== -->
<!-- .................................................. -->
<!-- fullscreen {{{2 -->
<!-- .................................................. -->
<script>
function fullscreen_onload() {
document.cancelFullScreen = document.webkitCancelFullScreen || document.mozCancelFullScreen;
// var elem = document.querySelector(document.webkitCancelFullScreen ? "#fs" : "#fs-container");
var elem = document.getElementById('videobox');
document.addEventListener('keydown', function(e) {
switch (e.keyCode) {
case 13: // ENTER. ESC should also take you out of fullscreen by default.
e.preventDefault();
document.cancelFullScreen(); // explicitly go out of fs.
break;
case 70: // f
enterFullscreen();
break;
}
}, false);
}
function toggleFS(el) {
if (el.webkitEnterFullScreen) {
el.webkitEnterFullScreen();
} else {
el.mozRequestFullScreen();
}
el.ondblclick = exitFullscreen;
}
function onFullScreenEnter() {
console.log("Entered fullscreen!");
elem.onwebkitfullscreenchange = onFullScreenExit;
elem.onmozfullscreenchange = onFullScreenExit;
};
// Called whenever the browser exits fullscreen.
function onFullScreenExit() {
console.log("Exited fullscreen!");
};
// Note: FF nightly needs about:config full-screen-api.enabled set to true.
function enterFullscreen() {
console.log("enterFullscreen()");
elem.onwebkitfullscreenchange = onFullScreenEnter;
elem.onmozfullscreenchange = onFullScreenEnter;
if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else {
elem.mozRequestFullScreen();
}
document.getElementById('enter-exit-fs').onclick = exitFullscreen;
}
function exitFullscreen() {
console.log("exitFullscreen()");
document.cancelFullScreen();
document.getElementById('enter-exit-fs').onclick = enterFullscreen;
}
</script>
<!-- .................................................. -->
<!-- fullscreen }}}2 -->
<!-- this document {{{2 -->
<!-- .................................................. -->
<script>
onload = onload_handler;
function onload_handler() {
fullscreen_onload();
}
</script>
<!-- .................................................. -->
<!-- this document }}}2 -->
<!-- Javascript }}} -->
<!-- ================================================== -->
</head>
<!-- ================================================== -->
<!-- START OF BODY -->
<body>
<!-- .................................................. -->
<div id="fs">
<video id="videobox" width="320" height="240" controls="controls" ondblclick="toggleFS(this)">
<source src="media/movie.mp4" type='video/mp4; codecs="avc1, mp4a"' />
<source src="media/movie.ogg" type='video/ogg; codecs="theora, vorbis"' />
Your browser does not support the video tag.
</video>
</div>
<!-- ================================================== -->
</body>
</html>