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.

              <link href="https://players.brightcove.net/videojs-overlay/2/videojs-overlay.css" rel='stylesheet'>

<video-js id="myPlayerID"
class="video-js" controls></video-js>

<script src="https://players.brightcove.net/1752604059001/default_default/index.min.js"></script>

  <!--include the Overlay plugin's JavaScript -->
  <script src="https://players.brightcove.net/videojs-overlay/2/videojs-overlay.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
/*size the player */
.video-js {
  height: 344px;
  width: 610px;
/* styling for the video thumbnails */
.video-thumbnail {
  margin: 0;
  padding: 0;
  width: 180px;
  height: 97px;
  cursor: pointer;
  border-style: solid;
/*override some of the default overlay styling*/
div.vjs-overlay.vjs-overlay-top {
  width: 100%;
  height: 90%;
  left: 0;
  margin-left: -1px;
              var loadAndPlay,

videojs.getPlayer('myPlayerID').ready(function() {
  myPlayer = this;
  var playlistID = 4609649081001,
      htmlElement = '',
      // build a div that will be used as overlay content
      overlayDiv = createEl('div', {
        id: 'bclsOverlay'
  // +++ Get the playlist +++
  // get the playlist using the catalog
  myPlayer.catalog.getPlaylist(playlistID, function(error, playlist){
    //deal with error
    returnedPlaylist = playlist;
    // be sure no more than 9 videos in playlist
    returnedPlaylist = returnedPlaylist.slice(0,9);
    // call function to use video objects to build div using thumbnails
    htmlElement = createVideoList(returnedPlaylist);
    // append div of thumbnails to overlay element
  // +++ Initialize the overlay +++
  // use overlay plugin to display related videos on pause and video end
  // note that only starting on pause event as on ended event a pause event is also dispatched
    overlays: [{
      align: 'top',
      content: overlayDiv,
      start: 'pause',
      end: 'play'

// +++ Load and play related video +++
     * loads and plays a video
     * this function called with thumbnails in
     * the overlay are clicked
     * @param {integer} idx the index of the video object in the videoData array
loadAndPlay = function(idx) {
     * create an element
     * @param  {string} type - the element type
     * @param  {object} attributes - attributes to add to the element
     * @return {HTMLElement} the HTML element
function createEl(type, attributes) {
  var el,
  el = document.createElement(type);
  if (attributes !== null) {
    for (attr in attributes) {
      el.setAttribute(attr, attributes[attr]);
    return el;

// +++ Format the overlay content +++
     * create the html for the overlay
     * @param {array} videoData array of video objects
     * @return {HTMLElement} videoList the div element containing the overlay
function createVideoList(videoData) {
  var i,
      iMax = videoData.length,
      videoList = createEl('div', {
        id: 'videoList'
      videoHeader = createEl('h1', {
        style: 'color:#666600;font-size: 2em;margin-bottom:.5em'
      videoWrapper = createEl('div'),
  for (i = 0; i < iMax; i++) {
    thumbnailLink = createEl('a', {
      href: 'javascript:loadAndPlay(' + i + ')'
    thumbnailImage = createEl('img', {
      class: 'video-thumbnail',
      src: videoData[i].thumbnail
  return videoList;
🕑 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 ..................