-
Notifications
You must be signed in to change notification settings - Fork 15
/
SignItVideosIframe.html
70 lines (63 loc) · 2.67 KB
/
SignItVideosIframe.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Load Video from URL Parameter</title>
</head>
<body>
<p id="no-video-url" style="display:none;">Video URL missing, try with suffix :
<a href="./SignItVideosIframe.html?width=380&twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm">
?width=380&twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm
</a>
</p>
<video id="signitVideoElement"
src="videoUrl" width="" class="" >
Your browser does not support the video tag.
</video>
<script>
/* USAGE ******************************************************* */
// ./SignItVideosIframe.html?twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm
document.addEventListener('DOMContentLoaded', function() {
// Function to get URL parameters
function getUrlParameter(name) {
const urlParams = new URLSearchParams(window.location.search);
return decodeURIComponent(urlParams.get(name)) || '';
}
// Get the video URL from the URL parameter
var videoUrl = getUrlParameter('video');
// Set the video source if the video URL exists
if (videoUrl) {
document.getElementById('signitVideoElement').src = videoUrl;
} else {
// Show the message if video URL is missing
document.getElementById('no-video-url').style.display = 'block';
}
// Pass size parameter
var width = getUrlParameter('width') || 380;
document.querySelector('video').style.width = width+'px';
// Pass speed parameter
var speedNormal = getUrlParameter('speedNormal') || 1,
speedSlow = getUrlParameter('speedSlow') || 0.5;
var twospeed = getUrlParameter('twospeed') || true;
console.log({videoUrl}, {speedNormal}, {speedSlow}, {twospeed}, {width});
if (twospeed === 'true') {
document.getElementById('signitVideoElement').addEventListener('ended', function(event) {
// Normal speed just played
if (!this.classList.contains('slow')) {
this.classList.add('slow');
this.playbackRate = speedSlow;
this.play();
}
// Slow speed just played
else {
this.classList.remove('slow');
this.playbackRate = speedNormal;
this.pause();
}
})
}
});
</script>
</body>
</html>