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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <button onclick="addPlayer()">Add Player</button>

<div id="placeHolder"></div>



                /* * 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: 640px;
  height: 360px;



                var myPlayer,
  // +++ Set the data for the player +++
  playerData = {
    accountId: "1752604059001",
    playerId: "rJtrO8EKW",
    videoId: "5550679964001"

// +++ Build the player and place in HTML DOM +++
function addPlayer() {
  // Dynamically build the player video element
  playerHTML =
    '<video-js id="myPlayerID" data-video-id="' +
    playerData.videoId +
    '"  data-account="' +
    playerData.accountId +
    '" data-player="' +
    playerData.playerId +
    '" data-embed="default" class="video-js" controls></video-js>';
  // Inject the player code into the DOM
  document.getElementById("placeHolder").innerHTML = playerHTML;
  // Add and execute the player script tag
  var s = document.createElement("script");
  s.src =
    "" +
    playerData.accountId +
    "/" +
    playerData.playerId +
  // Add the script tag to the document
  // Call a function to play the video once player's JavaScropt loaded
  s.onload = callback;

// +++ Initialize the player and start the video +++
function callback() {
  myPlayer = bc("myPlayerID");
  // Can also use the following to assign a player instance to the variable if you choose not to use IDs for elements directly
  // myPlayer = bc(document.getElementById('myPlayerID'));
  myPlayer.on("loadedmetadata", function() {
    // Mute the audio track, if there is one, so video will autoplay on button click