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

+ 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.


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.


                <!-- Player embed code with an id attribute -->
<video-js id="myPlayerID"
<script src=""></script>

<!-- Display the start position of the video as well as the current play position -->
<p>video start cookie value = <span id="cookieDisplay1"></span></p>
<p>current cookie value = <span id="cookieDisplay2"></span></p>


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


                videojs.getPlayer('myPlayerID').ready(function() {
  // Function to read the browser cookie
  var read_cookie = function (key) {
    var result;
    return (result = new RegExp('(^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? result[2] : null;

  // +++ Read browser cookie +++
  // Initialize variables and read the browser cookie associated with the Brightcove video position
  var myPlayer = this,
      videoStart = 0,
      cookie = read_cookie("BC_position");

  // +++ Check the cookie value +++
  // If the cookie exists, then set the video start position to this value. Otherwise, start from the beginning of the video.
  if(cookie != null){
        videoStart = cookie;
    } else {
        videoStart = 0;

    // +++ Start video playback +++
    // Wait for when the player is ready.
    myPlayer.on("loadeddata", function () {
      // If video position is greater than zero, than start playback at that point.
      if (videoStart > 0) {
    // Display the video start position
    document.getElementById("cookieDisplay1").innerHTML = videoStart;

    // +++ Increment the cookie +++
    // Listen for when the current playback position has changed. This should be every 15-250 milliseconds.
    myPlayer.on("timeupdate", function() {
      currentPosition = myPlayer.currentTime();
      // When the integer value changes, then update the cookie
      if (Math.round(currentPosition) != videoStart) {
        videoStart = Math.round(currentPosition);
        document.cookie="BC_position=" + escape(videoStart) + ";";
        // Display the current video position
        document.getElementById("cookieDisplay2").innerHTML = read_cookie("BC_position");

    // +++ Reset the cookie +++
    // When video playback reaches the end, then reset the cookie value to zero
    myPlayer.on("ended", function () {
        videoStart = 0;