Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="player-block">
    <!-- main container -->
    <div id="container">
      <!-- This container is for the clickable video poster image -->
    </div>

    <div id="playerLightbox" class="playerHide">
      <!-- lightbox container with player embed code -->

      <video-js id="myPlayerID"
        data-video-id="5625751316001"
        data-account="1752604059001"
        data-player="default"
        data-embed="default"
        data-application-id
        controls
        width="560"
        height="315"></video-js>
      
        <!-- close player button -->
        <div id="playerClose" class="playerClose" onClick="hideAndStop();">Close</div>
    </div>

    <script src="https://players.brightcove.net/1752604059001/default_default/index.min.js"></script>
  </div>
  <!-- id="player-block" -->
              
            
!

CSS

              
                /* * 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
 */
/* position the div which contains the video still image and the lightbox player */
.player-block {
  position: relative;
}
/* styles for the lightbox player, including transitions to show and hide */
#playerLightbox {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0;
  margin-left: 0;
  color: white;
  text-align: center;
  background-color: #333;
  border-radius: 5px;
  z-index: 20;
  overflow: hidden;
  -webkit-transition: all 500ms cubic-bezier(0.455, 0.030, 0.515, 0.955);
  -moz-transition: all 500ms cubic-bezier(0.455, 0.030, 0.515, 0.955);
  -ms-transition: all 500ms cubic-bezier(0.455, 0.030, 0.515, 0.955);
  -o-transition: all 500ms cubic-bezier(0.455, 0.030, 0.515, 0.955);
  transition: all 500ms cubic-bezier(0.455, 0.030, 0.515, 0.955);
  /* easeInOutQuad */
}
/* show the player */
.playerShow {
  width: 530px;
  height: 350px;
  padding: 10px;
  -webkit-box-shadow: 5px 5px 5px 5px rgba(151, 151, 151, .7);
  box-shadow: 5px 5px 5px 5px rgba(151, 151, 151, .7);
}
/* hide the player */
.playerHide {
  width: 0;
  height: 0;
  padding: 0;
}
/* style the close button for the lightbox player */
.playerClose {
  text-align: right;
  margin-top: 5px;
  text-decoration: underline;
  color: #63A7CE;
  width: 90%;
  cursor: pointer;
}

/* style the video poster image */
#container {
  position: relative;
  background-color: #090909;
  width: 320px;
  height: 180px;
  padding: 0px;
  border: 1px #999 solid;
  border-radius: 5px;
  cursor: pointer;
}
              
            
!

JS

              
                // Get a reference to the video poster image and the lightbox
var myPlayer,
    eContainer = document.getElementById("container"),
    eLightbox = document.getElementById("playerLightbox");

videojs.getPlayer('myPlayerID').ready(function() {
  // Get a reference to the player
  myPlayer = this;

  // +++ Wait for loadstart +++
  // Listen for the loadstart event
  myPlayer.on('loadstart',function(){
    var str = "";
    // Get the video's poster image and use it in the img tag
    str += '<img src="' +
      myPlayer.mediainfo.posterSources[0].src + '" alt="' +
      myPlayer.mediainfo.name + '" width="100%" height="100%"/>';
    eContainer.innerHTML = str;

    // +++ Listen for poster click +++
    // Add click event listener to the video poster image
    eContainer.onclick = function(e) {
      // reveal the lightbox
      eLightbox.className = "playerShow";
      // play the video
      myPlayer.play();
    }

    // +++ Close the lightbox +++
    // Listen for a click event on the close button
    playerClose.onclick = function(e) {
      myPlayer.pause();
      // hide the lightbox
      eLightbox.className = "playerHide";
    }
  })
});
              
            
!
999px

Console