Skip to content

Commit

Permalink
Update SignItVideosIframe.html
Browse files Browse the repository at this point in the history
Prettify
  • Loading branch information
hugolpz authored Jul 27, 2024
1 parent 27080ab commit 2c6fa56
Showing 1 changed file with 60 additions and 61 deletions.
121 changes: 60 additions & 61 deletions SignItVideosIframe.html
Original file line number Diff line number Diff line change
@@ -1,73 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<head>

<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?twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm">
?twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm
</a>
</head>

<body>
<p id="no-video-url" style="display:none;">Video URL missing, try with suffix :
<a href="./SignItVideosIframe.html?width=250&twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm">
?twospeed=true&video=https://upload.wikimedia.org/wikipedia/commons/6/63/Lapin_Nm_1_2_1_-_Elix.webm
</a>
</p>
<video id="signitVideoElement" controls="" muted="" preload="auto" autoplay="true" src="videoUrl" width="250" class="">
Your browser does not support the video tag.
</video>
<script>
<video id="signitVideoElement" controls="" muted="" preload="auto" autoplay="true" src="videoUrl" width="250" 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) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}

/* 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) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
// 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';
}

// 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') || 250;
document.getElementById('signitVideoElement').width = width;

// Pass size parameter
var width = getUrlParameter('width') || 250;
document.getElementById('signitVideoElement').width = width;
// Pass speed parameter
var speedNormal = getUrlParameter('speedNormal') || 1,
speedSlow = getUrlParameter('speedSlow') || 0.5;
var twospeed = getUrlParameter('twospeed') || true;

// 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});
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>
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>

1 comment on commit 2c6fa56

@hugolpz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just prettify

Please sign in to comment.