Pen Settings



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


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


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.


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.


                  <video-js id="myPlayerID" 
  <script src=""></script>

  <script src=""></script>



                @import url("//");

/* * 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

/* override default styles for overlay */
.videojs .vjs-overlay,
.vjs-overlay.vjs-overlay-top {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 100%;
  margin: auto;
  left: 0;
  top: 0;
  background: none;

/* hide the overlay */
.hide-overlay .vjs-overlay {
  display: none;
/* hide controls */ .vjs-control-bar,
.hide-controls .vjs-big-play-button {
  display: none;

/* set player size */
.video-js {
  width: 640px;
  height: 360px;

/* for the registration form */
/* form layout */
.registration-form {
  font-family: sans-serif;
  font-size: 0.9em;
  color: #333;
/* form header */
h1.registration-form {
  font-size: 1.1em;
/* buttons */
button.registration-form {
  font-size: 0.8em;
  padding: 0.4em;
  background-color: #234154;
  color: #fff;
  margin: 0.4em;
/* divs */
div.registration-form {
  background-color: #f5f5f5;
  opacity: 0.8;
  padding: 0.5em;

/* inputs */
div.registration-form input {
  width: 66%;
  display: inline;

/* paragraphs */
p.registration-form {
  font-weight: bold;
  margin: 0;



                videojs.getPlayer('myPlayerID').ready(function() {
  var myPlayer = this,
    // for handling the registration form
    // user info
    registered = false,
    // html for the registration form
    overlayContent =
      '<div id="regForm" class="registration-form"><h1 class="registration-form">To view the video, please register or login.</h1><p class="registration-form">First name: <input id="fname" type="text" size="30"></p><p>Last name: <input id="lname" type="text" size="30"></p><p class="registration-form">Email: <input id="email" type="text" size="35"></p><p class="registration-form"><button id="reg" class="registration-form">Register</button><button id="login" class="registration-form">Login</button><button id="noThanks" class="registration-form">No thanks</button></p></div><div id="regPass" class="registration-form" style="display:none;"><p class="registration-form">Choose a password: <input type="password" id="regPassword"></p><p class="registration-form"><button id="submitRegPassword" class="registration-form">Submit</button></p></div><div id="loginPass" class="registration-form" style="display:none;"><p class="registration-form">Enter your password: <input type="password" id="loginPassword"></p><p><button id="submitLoginPassword" class="registration-form">Submit</button></p></div><div id="noThanksMessage" style="display:none;"><p class="registration-form"><strong>Thanks for dropping by anyway!</strong></p></div>';

  // +++ Configure the Overlay +++
  // add the overlay content
    content: overlayContent,
    overlays: [
        align: "top",
        content: overlayContent,
        start: "play"

  // +++ Play video to trigger form display +++
  myPlayer.on("loadedmetadata", function() {;

  // +++ Get references to form elements, used in form processing +++
  // get element references
  var fname = document.getElementById("fname"),
    lname = document.getElementById("lname"),
    email = document.getElementById("email"),
    reg = document.getElementById("reg"),
    login = document.getElementById("login"),
    noThanks = document.getElementById("noThanks"),
    noThanksMessage = document.getElementById("noThanksMessage"),
    regForm = (document.getElementById(
    ).regPass = document.getElementById("regPass")),
    regPassword = document.getElementById("regPassword"),
    submitRegPassword = document.getElementById("submitRegPassword"),
    loginPass = document.getElementById("loginPass"),
    loginPassword = document.getElementById("loginPassword"),
    submitLoginPassword = document.getElementById("submitLoginPassword");

  // +++ Pause video on hide controls on player play +++"timeupdate", function() {

  // +++ Plays video when form filled out +++
       * hides the overlay, unhides the controls, and plays the video
       * this function is called from the registration form in the iframe
       * and that is why it is defined in the global scope
  playVideo = function() {
    // hide the overlay, show the controls, play

  // initially hide the controls

  // +++ Process the form +++//
  // everything below is for handling the registration form
  // decline event listener
  noThanks.addEventListener("click", function() {
    // show the goodbye message
    noThanksMessage.setAttribute("style", "display:block;");

  // register event listener
  reg.addEventListener("click", function() {
    // here you would want to validate the field values
    // show the create password form
    regPass.setAttribute("style", "display:block;");

  // login event listener
  login.addEventListener("click", function() {
    // here you would want to validate the field values
    // show the create password form
    loginPass.setAttribute("style", "display:block;");

  // registration password event listener
  submitRegPassword.addEventListener("click", function() {
    // here you would want to validate the field values
    firstName = fname.value;
    lastName = lname.value;
    emailAddress = email.value;
    password = regPassword.value;

    /* here you would submit the information to your
         * backend registration system and
         * handle the response
         * here we are skipping that and will
         * just set registered to true

    registered = true;

    // invoke the function on the parent page to play the video
    if (registered) {

  // login password event listener
  submitLoginPassword.addEventListener("click", function() {
    // here you would want to validate the field values
    firstName = fname.value;
    lastName = lname.value;
    emailAddress = email.value;
    password = loginPassword.value;

    // here you would submit the information to your
    // backend authentication system

    // if authentication succeeded,
    // invoke the function on the parent page to play the video