-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathsubtitles-and-captions.html
More file actions
329 lines (301 loc) · 10.1 KB
/
subtitles-and-captions.html
File metadata and controls
329 lines (301 loc) · 10.1 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Cloudinary Video Player</title>
<link
href="https://res.cloudinary.com/cloudinary-marketing/image/upload/f_auto,q_auto/c_scale,w_32,e_hue:290/creative_staging/cloudinary_internal/Website/Brand%20Updates/Favicon/cloudinary_web_favicon_192x192.png"
rel="icon"
type="image/png"
/>
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div class="container p-4 col-12 col-md-9 col-xl-6">
<nav class="nav mb-2">
<a href="/index.html"><< Back to examples index</a>
</nav>
<h1>Cloudinary Video Player</h1>
<h3 class="mb-4">Subtitles & Captions</h3>
<video
id="player"
playsinline
controls
muted
autoplay
class="cld-video-player cld-fluid"
crossorigin="anonymous"
width="500"
></video>
<h4 class="mt-4 mb-2">Playlist Subtitles (switch per source)</h4>
<video
id="playlist"
playsinline
controls
muted
class="cld-video-player cld-fluid"
crossorigin="anonymous"
width="500"
></video>
<h4 class="mt-4 mb-2">Paced & Styled Captions</h4>
<form>
<label for="maxWords">Max Words</label>
<input type="number" id="maxWords" name="maxWords" min="1" max="100" value="4" />
<label for="theme">Theme</label>
<select id="theme" name="theme">
<option value="default" selected>Default</option>
<option value="videojs-default">VideoJS Default</option>
<option value="player-colors">Player Colors</option>
<option value="yellow-outlined">Yellow Outlined</option>
<option value="3d">3D</option>
</select>
<label for="font">Font</label>
<select id="font" name="font">
<option value="Inter" selected>Inter</option>
<option value="Ceviche One">Ceviche One</option>
<option value="Merienda">Merienda</option>
<option value="Ultra">Ultra</option>
<option value="Kavoon">Kavoon</option>
<option value="Erica One">Erica One</option>
<option value="Corben">Corben</option>
<option value="Bungee Spice">Bungee Spice (Color)</option>
<option value="Nabla">Nabla (Color)</option>
</select>
<label for="gravity">Gravity</label>
<select id="gravity" name="gravity">
<option value="bottom" selected>Bottom</option>
<option value="bottom-left">Bottom Left</option>
<option value="bottom-right">Bottom Right</option>
<option value="top">Top</option>
<option value="top-left">Top Left</option>
<option value="top-right">Top Right</option>
<option value="center">Center</option>
<option value="center-left">Center Left</option>
<option value="center-right">Center Right</option>
</select>
<button type="button" id="apply">Apply</button>
</form>
<video
id="paced"
playsinline
controls
muted
class="cld-video-player cld-fluid"
crossorigin="anonymous"
width="500"
></video>
<h4 class="mt-4 mb-2">Karaoke player</h4>
<video
id="karaoke"
playsinline
controls
muted
class="cld-video-player cld-fluid"
crossorigin="anonymous"
width="500"
></video>
<p class="mt-4">
<a href="https://cloudinary.com/documentation/cloudinary_video_player"
>Full documentation</a
>
</p>
</div>
<script type="module">
import { videoPlayer } from 'cloudinary-video-player';
import 'cloudinary-video-player/cld-video-player.min.css';
import 'cloudinary-video-player/playlist';
const player = videoPlayer('player', {
cloudName: 'demo'
});
player.source('video-player/stubhub', {
textTracks: {
captions: {
label: 'English captions',
language: 'en',
default: true,
url: 'https://res.cloudinary.com/demo/raw/upload/v1636972013/video-player/vtt/Meetup_english.vtt'
},
subtitles: [
{
label: 'German subtitles',
language: 'de',
url: 'https://res.cloudinary.com/demo/raw/upload/v1636970250/video-player/vtt/Meetup_german.vtt'
},
{
label: 'Russian subtitles',
language: 'ru',
url: 'https://res.cloudinary.com/demo/raw/upload/v1636970275/video-player/vtt/Meetup_russian.vtt'
}
]
}
});
// Playlist
const playlist = videoPlayer('playlist', {
cloudName: 'demo'
});
const source1 = {
publicId: 'video-player/stubhub',
info: { title: 'Subtitles & Captions playlist' },
textTracks: {
captions: {
label: 'English captions',
language: 'en',
default: true,
url: 'https://res.cloudinary.com/demo/raw/upload/v1636972013/video-player/vtt/Meetup_english.vtt'
},
subtitles: [
{
label: 'German subtitles',
language: 'de',
url: 'https://res.cloudinary.com/demo/raw/upload/v1636970250/video-player/vtt/Meetup_german.vtt'
},
{
label: 'Russian subtitles',
language: 'ru',
url: 'https://res.cloudinary.com/demo/raw/upload/v1636970275/video-player/vtt/Meetup_russian.vtt'
}
]
}
};
const source2 = {
publicId: 'video-player/outdoors',
info: { title: 'Outdoors', subtitle: 'Outdoors movie with captions' },
textTracks: {
captions: {
label: 'English captions',
language: 'en',
default: true,
url: 'https://res.cloudinary.com/demo/raw/upload/v1636971261/video-player/vtt/outdoors.vtt'
}
}
};
const source3 = {
publicId: 'video-player/dog',
info: { title: 'Dog', subtitle: 'Video of a dog, no captions' }
};
const playlistSources = [source1, source2, source3];
const playlistOptions = {
autoAdvance: true,
repeat: true,
presentUpcoming: 8
};
playlist.playlist(playlistSources, playlistOptions);
// Paced
const pacedPlayer = cloudinary.videoPlayer('paced', {
cloudName: 'prod'
});
const publicId = 'video/examples/cloudinary-marketing';
const textTracks = {
options: {
// theme: "", // one of 'default', 'videojs-default', 'yellow-outlined', 'player-colors' & '3d'
// fontFace: "", // any Google font
// fontSize: "", // any CSS value
// gravity: "", // i.e. 'top-left', 'center' etc
// box: { // Object of x/y/width/height
// x: "0%",
// y: "0%",
// width: "100%",
// height: "100%"
// },
// style: { // Styles key-value object
// color: "hotpink"
// }
},
captions: {
label: 'English Paced',
maxWords: 4,
default: true,
}
}
pacedPlayer.source(publicId, {
textTracks
});
const maxWordsInput = document.getElementById('maxWords');
const themeSelect = document.getElementById('theme');
const fontSelect = document.getElementById('font');
const gravitySelect = document.getElementById('gravity');
const applyButton = document.getElementById('apply');
applyButton.addEventListener('click', function () {
textTracks.captions.maxWords = parseInt(maxWordsInput.value);
textTracks.options.theme = themeSelect.value;
textTracks.options.fontFace = fontSelect.value;
textTracks.options.gravity = gravitySelect.value;
pacedPlayer.source(publicId, {
textTracks
});
});
// Karaoke
const karaokePlayer = cloudinary.videoPlayer('karaoke', {
cloudName: 'prod'
});
karaokePlayer.source('video/examples/cld-imagine_1080p', {
textTracks: {
options: {
fontFace: 'Lobster',
fontSize: '200%',
gravity: 'top',
wordHighlightStyle: {
color: 'white',
'text-shadow': `2px 2px 0px violet,
4px 4px 0px indigo,
6px 6px 0px blue,
8px 8px 0px green,
10px 10px 0px yellow,
12px 12px 0px orange,
14px 14px 0px red`
}
},
captions: {
label: 'KARAOKE',
wordHighlight: true,
maxWords: 8,
url: 'https://res.cloudinary.com/prod/raw/upload/v1/video/examples/cld-imagine_1080p.transcript',
default: true
}
}
});
// Auto-translated transcript
const translatedTranscriptPlayer = cloudinary.videoPlayer('translated-transcript', {
cloudName: 'prod'
});
translatedTranscriptPlayer.source('video/examples/cloudinary-marketing-pm', {
textTracks: {
captions: {
label: "Original",
default: true,
},
subtitles: [
{
label: "English",
language: "en-US",
},
{
label: "Polish",
language: "pl-PL",
},
{
label: "Hebrew",
language: "he-IL",
},
{
label: "Italian",
language: "it-IT",
},
{
label: "Ukrainian",
language: "uk-UA",
}
]
}
});
</script>
<!-- Bootstrap -->
<link
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
</body>
</html>