JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="container">
<div class="text__container">
<h1>YouTube Video Background</h1>
<p>Using the YouTube iFrame Player API,
<br /> Does not work on iOS :(</p>
</div>
<div class="player__container">
<div class="overlay"></div>
<div id="player"></div>
</div>
</div>
$bg_pattern: ' data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAATklEQVQYV2NkYGAwZmBgOMuAACA+CKCIMSIpADGRNaEYgKwQ3WQUjTCF6CYhWw2WAynEpgjmIpg7jUlSiM0TWK2GWUOUZ7ApxggeogIcABHJFtfoX9tJAAAAAElFTkSuQmCC'
$bg_image: 'https://i.ytimg.com/vi/1kKkRtVlwrM/maxresdefault.jpg'
$font_family: Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT", "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif
*
box-sizing: border-box
body
margin: 0
font-family: $font_family
background-color: black
background-image: url($bg_image)
background-repeat: no-repeat
background-size: cover cover
height: 100%
.container
max-height: 400px
margin: 0 auto
margin-top: 2em
position: relative
overflow: hidden
width: 80%
border: 6px solid rgba(#eee, .4)
.player__container
position: relative
padding-bottom: 56.25%
height: 0
overflow: hidden
max-width: 100%
.overlay
height: 100%
width: 100%
display: block
z-index: 1
position: absolute
background-color: rgba(blue, .2)
background-repeat: repeat
//background-image: url($bg_pattern)
iframe, embed, object
position: absolute
top: 0
left: 0
width: 100%
height: 100%
z-index: -99
//transform: translateY(-200px)
.text__container
position: absolute
padding: 2em
height: 100%
width: 100%
z-index: 3
h1, p
text-align: center
color: white
h1
font-size: 2.2em
font-weight: 300
text-transform: uppercase
width: 100%
p
font-size: 1.1em
border: 3px solid rgba(white, .1)
background-color: rgba(white ,.1)
width: 40%
min-width: 360px
padding: 1em 2em
margin: 0 auto
// https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
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: 'KL6jwnIln6w',
playerVars: {
autoplay: 1,
autohide: 1,
controls: 0,
iv_load_policy: 3,
fs: 0,
loop: 1,
mute: 1,
showinfo: 0,
modestbrangin: 1,
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerReady
}
});
}
function onPlayerReady(event) {
event.target.playVideo();
// disable audio
player.mute();
}
Also see: Tab Triggers