Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                <video-js id="myPlayerID" 
  data-account="1752604059001" 
  data-player="HCDs9Wxen" 
  data-embed="default" 
  controls="" 
  data-video-id="5992439742001" 
  data-playlist-id="" 
  data-application-id="" 
  width="640" height="360"></video-js>
<script src="https://players.brightcove.net/1752604059001/HCDs9Wxen_default/index.min.js"></script>

              
            
!

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
 */
#backButton img {
  margin-top: -7px;
  height: 45px;
  width: 45px;
  cursor: pointer;
}
#forwardButton img {
  margin-top: -7px;
  height: 45px;
  width: 45px;
  cursor: pointer;
}

              
            
!

JS

              
                videojs.getPlayer("myPlayerID").ready(function() {
  // +++ Create divs for buttons +++
  var myPlayer = this,
    jumpAmount = 5,
    controlBar,
    insertBeforeNode,
    newElementBB = document.createElement("div"),
    newElementFB = document.createElement("div"),
    newImageBB = document.createElement("img"),
    newImageFB = document.createElement("img");

  // +++ Assign IDs for later element manipulation +++
  newElementBB.id = "backButton";
  newElementFB.id = "forwardButton";

  // +++ Assign properties to elements and assign to parents +++
  newImageBB.setAttribute(
    "src",
    "https://player.support.brightcove.com/assets/images/code-samples/brightcove-player-sample-back-forward-buttons/back-button.png"
  );
  newElementBB.appendChild(newImageBB);
  newImageFB.setAttribute(
    "src",
    "https://player.support.brightcove.com/assets/images/code-samples/brightcove-player-sample-back-forward-buttons/forward-button.png"
  );
  newElementFB.appendChild(newImageFB);

  // +++ Get controlbar and insert elements +++
  controlBar = myPlayer.$(".vjs-control-bar");
  // Get the element to insert buttons in front of in conrolbar
  insertBeforeNode = myPlayer.$(".vjs-volume-panel");

  // Insert the button div in proper location
  controlBar.insertBefore(newElementBB, insertBeforeNode);
  controlBar.insertBefore(newElementFB, insertBeforeNode);

  // +++ Add event handlers to jump back or forward +++
  // Back button logic, don't jump to negative times
  newElementBB.addEventListener("click", function() {
    var newTime,
      rewindAmt = jumpAmount,
      videoTime = myPlayer.currentTime();
    if (videoTime >= rewindAmt) {
      newTime = videoTime - rewindAmt;
    } else {
      newTime = 0;
    }
    myPlayer.currentTime(newTime);
  });

  // Forward button logic, don't jump past the duration
  newElementFB.addEventListener("click", function() {
    var newTime,
      forwardAmt = jumpAmount,
      videoTime = myPlayer.currentTime(),
      videoDuration = myPlayer.duration();
    if (videoTime + forwardAmt <= videoDuration) {
      newTime = videoTime + forwardAmt;
    } else {
      newTime = videoDuration;
    }
    myPlayer.currentTime(newTime);
  });
});

              
            
!
999px

Console