Reputation: 2302
I wonder if it is possible to see a Youtube Video Thumbnail before loading the video itself?
Here is an example of what I have at moment:
<html>
<head>
<style>
.video-background {
position: fixed;
top: 0; right: 0; bottom: 0; left: 0;
z-index: -99;
}
.video-foreground,
.video-background iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
@media (min-aspect-ratio: 16/9) {
.video-foreground { height: 300%; top: -100%; }
}
@media (max-aspect-ratio: 16/9) {
.video-foreground { width: 300%; left: -100%; }
}
</style>
</head>
<body>
<div class="video-background">
<div class="video-foreground">
<iframe src="https://www.youtube.com/embed/PR97m89_s4c?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=PR97m89_s4c" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</body>
</html>
https://codepen.io/jacksonjack/pen/VypELM
It loads the video but the first 2-3 seconds whilst it loads are a black screen.
Suggestions?
Upvotes: 1
Views: 592
Reputation: 93
You should use a bit of JS code to prevent the loading time like 5 second and after show the video up... Add at that a fade while opening the loaded video and that's done :)
Upvotes: 1