css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

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.

            
              <p>Duis ullamcorper varius vulputate. Mauris et purus neque. Duis at erat vulputate purus mattis blandit ac id erat. Nullam tempor metus in lorem aliquam gravida. Nullam id eros condimentum dui maximus posuere non et neque. Fusce dapibus neque finibus nunc accumsan lobortis.</p>
<p>Duis ullamcorper varius vulputate. Mauris et purus neque. Duis at erat vulputate purus mattis blandit ac id erat. Nullam tempor metus in lorem aliquam gravida. Nullam id eros condimentum dui maximus posuere non et neque. Fusce dapibus neque finibus nunc accumsan lobortis.</p>
<p>Curabitur scelerisque mi a ante euismod congue. Suspendisse rhoncus, odio non faucibus cursus, metus diam vestibulum velit, eu commodo nunc orci et purus. Sed eget ultrices sem. Nullam egestas ipsum augue, eu condimentum ipsum bibendum ac. Phasellus varius orci eget est aliquam posuere. Nam ornare at felis ut fermentum. Suspendisse auctor ultricies augue vitae dapibus. Nam efficitur urna velit, quis interdum augue vestibulum et. Pellentesque aliquam, massa et condimentum viverra, lacus est mattis ipsum, nec facilisis eros tortor quis justo.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis est et libero ultricies condimentum. Suspendisse ut ante sed leo consequat cursus eget a ex. Etiam aliquet augue sed elit aliquet iaculis. Nunc iaculis ultrices congue. Pellentesque at enim sapien. Donec nec semper sem. Aenean dui quam, euismod vel commodo nec, cursus tempor risus. Donec ligula mi, imperdiet quis lorem id, blandit semper dolor. Duis accumsan tempor malesuada.</p>

  <video-js id="myPlayerID"
    data-video-id="4172255216001"
    data-account="1752604059001"
    data-player="b74dc6ed-69d3-482e-bf48-49d0cf10d424"
    data-embed="default"
    class="video-js"
    controls
    muted></video-js>

  <p>Duis ullamcorper varius vulputate. Mauris et purus neque. Duis at erat vulputate purus mattis blandit ac id erat. Nullam tempor metus in lorem aliquam gravida. Nullam id eros condimentum dui maximus posuere non et neque. Fusce dapibus neque finibus nunc accumsan lobortis.</p>
  <p>Curabitur scelerisque mi a ante euismod congue. Suspendisse rhoncus, odio non faucibus cursus, metus diam vestibulum velit, eu commodo nunc orci et purus. Sed eget ultrices sem. Nullam egestas ipsum augue, eu condimentum ipsum bibendum ac. Phasellus varius orci eget est aliquam posuere. Nam ornare at felis ut fermentum. Suspendisse auctor ultricies augue vitae dapibus. Nam efficitur urna velit, quis interdum augue vestibulum et. Pellentesque aliquam, massa et condimentum viverra, lacus est mattis ipsum, nec facilisis eros tortor quis justo.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis est et libero ultricies condimentum. Suspendisse ut ante sed leo consequat cursus eget a ex. Etiam aliquet augue sed elit aliquet iaculis. Nunc iaculis ultrices congue. Pellentesque at enim sapien. Donec nec semper sem. Aenean dui quam, euismod vel commodo nec, cursus tempor risus. Donec ligula mi, imperdiet quis lorem id, blandit semper dolor. Duis accumsan tempor malesuada.</p>
  <p>Duis ullamcorper varius vulputate. Mauris et purus neque. Duis at erat vulputate purus mattis blandit ac id erat. Nullam tempor metus in lorem aliquam gravida. Nullam id eros condimentum dui maximus posuere non et neque. Fusce dapibus neque finibus nunc accumsan lobortis.</p>
  <p>Curabitur scelerisque mi a ante euismod congue. Suspendisse rhoncus, odio non faucibus cursus, metus diam vestibulum velit, eu commodo nunc orci et purus. Sed eget ultrices sem. Nullam egestas ipsum augue, eu condimentum ipsum bibendum ac. Phasellus varius orci eget est aliquam posuere. Nam ornare at felis ut fermentum. Suspendisse auctor ultricies augue vitae dapibus. Nam efficitur urna velit, quis interdum augue vestibulum et. Pellentesque aliquam, massa et condimentum viverra, lacus est mattis ipsum, nec facilisis eros tortor quis justo.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis est et libero ultricies condimentum. Suspendisse ut ante sed leo consequat cursus eget a ex. Etiam aliquet augue sed elit aliquet iaculis. Nunc iaculis ultrices congue. Pellentesque at enim sapien. Donec nec semper sem. Aenean dui quam, euismod vel commodo nec, cursus tempor risus. Donec ligula mi, imperdiet quis lorem id, blandit semper dolor. Duis accumsan tempor malesuada.</p>
  <p>Duis ullamcorper varius vulputate. Mauris et purus neque. Duis at erat vulputate purus mattis blandit ac id erat. Nullam tempor metus in lorem aliquam gravida. Nullam id eros condimentum dui maximus posuere non et neque. Fusce dapibus neque finibus nunc accumsan lobortis.</p>
  <p>Curabitur scelerisque mi a ante euismod congue. Suspendisse rhoncus, odio non faucibus cursus, metus diam vestibulum velit, eu commodo nunc orci et purus. Sed eget ultrices sem. Nullam egestas ipsum augue, eu condimentum ipsum bibendum ac. Phasellus varius orci eget est aliquam posuere. Nam ornare at felis ut fermentum. Suspendisse auctor ultricies augue vitae dapibus. Nam efficitur urna velit, quis interdum augue vestibulum et. Pellentesque aliquam, massa et condimentum viverra, lacus est mattis ipsum, nec facilisis eros tortor quis justo.</p>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="https://players.brightcove.net/1752604059001/b74dc6ed-69d3-482e-bf48-49d0cf10d424_default/index.min.js"></script>
            
          
!
            
              /* * The body style is just for the
 * background color of the codepen.
 * Do not include in your code.
 */
body {
  background-color: #111;
  color: #fff;
}
/*
 * Styles essential to the sample
 * are below
 */
.video-js {
  width: 480px;
  height: 270px;
}

            
          
!
            
              videojs.getPlayer('myPlayerID').ready(function() {
  var myPlayer = this;

  // +++ Execute every time page is scrolled +++
  window.onscroll = checkIfVideoInView;

  // +++ Called on scroll, check if in view and the play/pause +++
  function checkIfVideoInView() {
    if (isScrolledIntoView(myPlayerID)) {
      // the player is fully in the viewport
      myPlayer.play();
    } else {
      // the player is not in the viewport
      myPlayer.pause();
    }
  }

  // +++ Checks if player is in view +++
  function isScrolledIntoView(elem) {
    // Get the position of the viewport
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    // get the position of the player element
    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    // Determine if the player element is in fully in the viewport
    return (
      elemBottom >= docViewTop &&
      elemTop <= docViewBottom &&
      elemBottom <= docViewBottom &&
      elemTop >= docViewTop
    );
  }
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console