Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoplay YouTube Video Background Tiles

Tags:

jquery

youtube

Fiddle: https://codepen.io/anon/pen/ZyLqPd
Fiddle with YTVideos: https://codepen.io/anon/pen/KqXavy?editors=0100

http://www.seanmccambridge.com/tubular/ https://pupunzi.com/#mb.components/mb.YTPlayer/YTPlayer.html

Are there are libraries out there that easily enable adding a background youtube video to a div?

I've searched over and over and couldn't find anything.

Essentially I want to play a YouTube video as the background for the divs with the images in this screenshot.

enter image description here

$('.canvas .box').YTPlayer({
    fitToBackground: true,
    videoId: '-JlcxL2ux_A'
});
like image 963
Michael Schwartz Avatar asked Jun 18 '17 09:06

Michael Schwartz


1 Answers

in your mockup the videos have a normal 16:9 aspect ratio, so that's what i went with instead of the squares you initially had. here are the tweaks:

https://codepen.io/saetia/full/BZwWdx/

video boxes

<div class="ib box">
    <div class="responsive"><iframe src="https://www.youtube.com/embed/8nH-49PgKdw?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&playlist=W0LHTWG-UmQ" frameborder="0" allowfullscreen></iframe></div>
</div>

styles

.canvas .box {
  display: inline-block;
  width: 25%;
  pointer-events: none;
}
.canvas .box .responsive {
  position: relative;
  height: 0;
  overflow: hidden;
  padding-bottom: 56.25%;
}
.canvas .box iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
like image 63
Joel Glovacki Avatar answered Nov 08 '22 16:11

Joel Glovacki