-
Notifications
You must be signed in to change notification settings - Fork 7.4k
/
hotkeys.html.example
158 lines (150 loc) · 5.89 KB
/
hotkeys.html.example
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Video.js Hotkeys - Sandbox</title>
<link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script>
<style>
.hotkeys-function { background: #FF6961; }
.hotkeys-override { background: #77DD77; }
.hotkeys-normal { background: #AEC6CF; }
.video-js {
height: 150px;
width: 300px;
}
.wrapper {
display: grid;
margin: 0 auto;
grid-gap: 10px;
grid-template-columns: 300px 300px 300px;
}
.panel > p:first-child {
border-bottom: black 1px solid;
}
</style>
</head>
<body>
<h1>Video.js Hotkeys</h1>
<p>All the various ways to configure hotkeys.</p>
<div class="wrapper">
<div class="panel hotkeys-normal">
<p>Default (no) hotkeys</p>
<video-js
id="vid0"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png">
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm">
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg">
<track kind="captions" src="../docs/examples/shared/example-captions.vtt" srclang="en" label="English">
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video-js>
</div>
<div class="panel hotkeys-normal">
<p>Disable hotkeys</p>
<video-js
id="vid1"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png">
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm">
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg">
<track kind="captions" src="../docs/examples/shared/example-captions.vtt" srclang="en" label="English">
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video-js>
</div>
<div class="panel hotkeys-normal">
<p>Enable default hotkeys (k = play/pause, m = mute/unmute, f = fullscreen)</p>
<video-js
id="vid12"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png">
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm">
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg">
<track kind="captions" src="../docs/examples/shared/example-captions.vtt" srclang="en" label="English">
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video-js>
</div>
<div class="panel hotkeys-function">
<p>Custom hotkey function (x = pause, y = play)</p>
<video-js
id="vid2"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png">
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm">
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg">
<track kind="captions" src="../docs/examples/shared/example-captions.vtt" srclang="en" label="English">
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video-js>
</div>
<div class="panel hotkeys-override">
<p>Customize specific hotkeys (z = play/pause, v = fullscreen)</p>
<video-js
id="vid3"
controls
preload="auto"
poster="//vjs.zencdn.net/v/oceans.png">
<source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm">
<source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg">
<track kind="captions" src="../docs/examples/shared/example-captions.vtt" srclang="en" label="English">
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video-js>
</div>
</div>
<script>
var player0 = videojs('vid0', {});
// Note that we support both explicitly disbling and explicitly enabling Hotkeys
// because one day the default may change from disabled to enabled.
var player1 = videojs('vid1', {
userActions: {
hotkeys: false
}
});
var player12 = videojs('vid12', {
userActions: {
hotkeys: true
}
});
var player2 = videojs('vid2', {
userActions: {
hotkeys: function(event) {
// `this` is the player in this context
// `x` key = pause
if (event.which === 88) {
this.pause();
}
// `y` key = play
if (event.which === 89) {
this.play();
}
}
}
});
var player3 = videojs('vid3', {
userActions: {
hotkeys: {
playPauseKey: function(event) {
// override play/pause to trigger when pressing the z key
return (event.which === 90);
},
muteKey: function(event) {
// disable mute key
},
fullscreenKey: function(event) {
// override fullscreen to trigger when pressing the v key
return (event.which === 86);
}
}
}
});
</script>
</body>
</html>