-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathmeta3.html
More file actions
190 lines (176 loc) · 5.82 KB
/
meta3.html
File metadata and controls
190 lines (176 loc) · 5.82 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Responsive video with clickable hotspots | Able Player Demos</title>
<link rel="stylesheet" href="demos.css" type="text/css">
<!-- Dependencies -->
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js" integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=" crossorigin="anonymous"></script>
<!-- Able Player CSS -->
<link rel="stylesheet" href="../build/ableplayer.min.css" type="text/css"/>
<!-- Able Player JavaScript -->
<script src="../build/ableplayer.dist.js"></script>
<!-- CSS for hidden blocks on content in this example -->
<style>
div#video-and-meta-wrapper {
position: relative;
}
div.meta {
position: absolute;
z-index: 10000;
display: none;
}
div#info,
div#instructions {
background-color: #ffc;
border: 3px solid #412C84;
color: #000;
font-size: 1.2em;
line-height: 1.25em;
padding: 0.5em;
}
div#info {
top: 11.111%; /* 40px */
left: 4.167%; /* 20px */
width: 41.667%; /* 200px */
height: auto;
}
div#instructions {
top: 66.667%; /* 240px */
left: 18.75%; /* 90px */
width: 41.667%; /* 200px */
height: auto;
}
div#instructions:focus,
div#terrill:focus,
div#terrill:hover {
border: 3px solid #C00;
}
div#terrill {
top: 11.111%; /* 40px */
left: 28.333%; /* 136px */
width: 25%; /* 120px */
height: 38.889%; /* 140px; */
background-color: #FFF;
border: 3px solid #412C84;
opacity: 0.3;
}
div#terrill:focus {
border: 3px solid yellow;
}
div#response {
top: 11.111%; /* 40px */
right: 16.667%; /* 80px */
width: 31.25%; /* 150px */
height: 25%; /* 90px */
background-image: url('cartoon-bubble.png');
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
font-weight: bold;
font-size: 1.2em;
padding-top: 5.556%; /* 20px */
text-align: center;
}
</style>
<!-- Script for this example -->
<script>
$(document).ready(function() {
// To absolute-position block overlays on video,
// a parent of both video & overlays (in this case, div#video-and-meta-wrapper)
// must be positioned with width and height
// However, with fixed width and height the video is not responsive using CSS alone
// So, we need to use JavaScript to calculate and assign the width and height
// *after* the responsive video has been sized with CSS to fit its container
// This calculation then must be re-executed if the window is resized
var videoDefaultWidth, videoDefaultHeight,
videoWidth, videoHeight;
$(window).on('load resize',function(event) {
if (event.type === 'load') {
// initializing for the first time
videoWidth = $('#video1').width();
videoHeight = $('#video1').height();
}
if (event.type === 'resize') {
// window has been resized.
// can't determine videoWidth via method used on load
// because video is now has an assigned (unresponsive) width
// Remove these attributes temporarily, then recalculate & reassign
$('#video-and-meta-wrapper').css({
'width': '',
'height': ''
});
videoWidth = $('#video1').width();
videoHeight = $('#video1').height();
}
// asign calculated width and height values to wrapper
$('#video-and-meta-wrapper').css({
'width': videoWidth + 'px',
'height': videoHeight + 'px'
});
});
// The rest is the same as Demo #8
// Handle clicks on the exposed overlay blocks
$('#instructions').on('focus',function() {
$('#terrill').attr('tabindex','0');
})
$('#terrill').on('click',function() {
toggleResponse();
});
$('#terrill').on('keypress',function(e) {
if (e.which === 13 || e.which === 32) {
toggleResponse();
}
});
});
function toggleResponse() {
if ($('#response').is(':visible')) {
$('#response').hide();
} else {
// response is an interactive element not included in metadata file
// therefore it doesn't disappear automatically
$('#response').show().delay(5000).fadeOut();
}
}
</script>
</head>
<body>
<header>
<div class="title">Able Player Demos</div>
</header>
<nav>
<ul>
<li><a href="index.html">More demos</a></li>
<li><a href="https://ableplayer.github.io/ableplayer">Able Player Home</a></li>
</ul>
</nav>
<main>
<h1>Responsive video with clickable hotspots</h1>
<p>This example has the same functionality as <a href="meta2.html">Metadata Demo #2</a>.
Both examples demonstrate using a WebVTT metadata track to expose content
as an overlay on the video.
</p>
<p>
However, in the other demo the video is positioned with fixed width and height.
This is necessary to precisely position overlay content atop the video using pixel values.
The current example implements this same feature in a responsive design,
with overlay content positioned using percentage values.
</p>
<div id="video-and-meta-wrapper">
<video id="video1" preload="auto" poster="../media/wwa.jpg" data-able-player data-meta-type="selector" playsinline>
<source type="video/mp4" src="../media/wwa.mp4" data-desc-src="../media/wwa_described.mp4"/>
<source type="video/webm" src="../media/wwa.webm" data-desc-src="../media/wwa_described.webm"/>
<!-- Able Player will display tracks alphabetically by label -->
<track kind="captions" src="../media/wwa_captions_en.vtt" srclang="en" label="English"/>
<track kind="metadata" src="../media/wwa_meta.vtt" srclang="en"/>
</video>
<!-- metadata content -->
<div class="meta" id="info" role="alert">Supplemental content displayed briefly during a break in the audio</div>
<div class="meta" id="instructions" role="alert" tabindex="-1">What happens if you click Terrill's face?</div>
<div class="meta" id="terrill" role="button" aria-label="Terrill's face" tabindex="-1"></div>
<div class="meta" id="response" role="alert">Ouch!</div>
</div>
</main>
</body>
</html>