JSFiddle - React, Tailwind, and code Playground
by netsi1964
HTML
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="filter">
<!-- Colors: -->
<feFlood flood-color="#986AA9" flood-opacity="1" result="COL_green-l"></feFlood>
<feFlood flood-color="#986AA9" flood-opacity="1" result="COL_green-m"></feFlood>
<feFlood flood-color="#986AA9" flood-opacity="1" result="COL_green-d"></feFlood>
<feFlood flood-color="#986AA9" flood-opacity="1" result="COL_red-l"></feFlood>
<feFlood flood-color="#986AA9" flood-opacity="1" result="COL_red-d"></feFlood>
<feFlood flood-color="rgba(0,0,0,0)" flood-opacity="0" result="TRANSPARENT"></feFlood>
<!-- Colors end -->
<!-- Lower Green Bevel -->
<feMorphology operator="dilate" radius="1" in="SourceAlpha" result="GREEN-BEVEL-1_10"></feMorphology>
<feConvolveMatrix order="8,8" divisor="1" kernelMatrix="1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1" in="GREEN-BEVEL-1_10" result="GREEN-BEVEL-1_20"></feConvolveMatrix>
<feComposite operator="in" in="COL_green-d" in2="GREEN-BEVEL-1_20" result="GREEN-BEVEL-1_30"></feComposite>
<!-- Lower Green Bevel End -->
<!-- Lower Green Front -->
<feComposite operator="in" in="COL_green-l" in2="GREEN-BEVEL-1_10" result="GREEN-FRONT-1_0"></feComposite>
<feOffset dx="4" dy="4" in="GREEN-FRONT-1_0" result="GREEN-FRONT-1_10"></feOffset>
<feSpecularLighting surfaceScale="0" specularConstant=".75" specularExponent="30" lighting-color="#white" in="GREEN-FRONT-1_10" result="GREEN-FRONT-1_20">
<fePointLight x="0" y="-30" z="400"></fePointLight>
</feSpecularLighting>
<feComposite operator="out" in2="GREEN-FRONT-1_20" in="GREEN-FRONT-1_10" result="GREEN-FRONT-1_30"></feComposite>
<!-- Lower Green Front End -->
<!-- Upper...
CSS
html {
height: 100%;
}
body {
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/9729/background.svg')
no-repeat
center
center,
#69008C
radial-gradient(
ellipse at center,
rgba(70, 0, 103, 0.8) 10%,
rgba(70, 0, 103, 0.1) 100%
);
background-size: cover;
background-attachment: fixed;
height: 100%;
margin: 0;
padding: 0;
}
::selection {
background: #4CFED7;
}
::-moz-selection {
background: #4CFED7;
}
svg {
display: block;
position: relative;
width: 510px;
height: 300px;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
margin: 0 auto;
overflow: hidden;
}
.filtered {
filter: url(#filter);
-webkit-filter: url(#filter);
color: #4CFED7;
fill: #4CFED7;
font-family: 'Sancreek', cursive;
font-size: 170px;
font-weight: 700;
}
.overlay {
font-family: sans-serif;
position: absolute;
z-index: 1;
display: flex;
flex-direction: row;
box-sizing: border-box;
}
.overlay a {
text-decoration: none;
color: white;
opacity: .4;
}
.overlay a:hover {
opacity: 1;
}
.overlay i {
color: white;
font-size: 12pt;
}
.fa-stop, .overlay.playing .fa-play, .fa-pause {
display: none;
}
.overlay.playing .fa-stop,
.overlay.playing .fa-pause
{
display: block;
}
#graphics {
right: 12px;
bottom: 10px;
}
#youtube {
top: 10px;
left: 12px;
display: flex;
flex-direction: row;
justify-content: space-between;
width: calc(100% - 14px);
max-width: 500px;
}
iframe, #player {display: none;}
JavaScript
var at = 0,
time = document.querySelector(".time"),
youtube = document.querySelector("#youtube"),
fa_youtube_play = document.querySelector(".fa-youtube-play"),
fa_play = document.querySelector(".fa-play"),
fa_pause = document.querySelector(".fa-pause"),
fa_stop = document.querySelector(".fa-stop"),
timeupdate;
var tag = document.createElement("script");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player("player", {
height: "390",
width: "640",
videoId: "FQYNz785iGs",
events: {
onReady: onPlayerReady,
onStateChange: onPlayerStateChange
}
});
}
console.log('onYouTubeIframeAPIReady')
function onPlayerReady(event) {
fa_play.addEventListener("click", startVideo);
fa_stop.addEventListener("click", function() {stopVideo(true)});
fa_pause.addEventListener("click", stopVideo);
startVideo();
console.log('onPlayerReady')
}
function showCurrentTime() {
time.innerText = player.getCurrentTime();
console.log('showCurrentTime')
}
function startVideo() {
try {
//if (timeupdate) clearInterval(timeupdate);
timeupdate = setInterval(showCurrentTime, 1000);
player.playVideoAt(at);
youtube.classList.add("playing");
} catch(e) {
console.log("Error in startVideo: ", e.message)
}
console.log('startVideo')
}
function stopVideo(reset) {
at = reset ? 0 : player.getCurrentTime();
if (timeupdate) clearInterval(timeupdate);
player.stopVideo();
youtube.classList.remove("playing");
console.log('stopVideo')
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 7000);
done =...