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.

              <section class="bcls-section">
  <h2 id="video_data">Video data</h2>

  <p>This script expects a data set as a JSON array of objects like this:</p>

  <p>Video data:</p>
    <textarea id="videoData" class="bcls-code">[
        "name": "Oyster Catcher",
        "id": "4865852541001"
        "name": "Brown Pelican",
        "id": "4752142999001"
        "name": "Great Blue Heron",
        "id": "5455488372001"
        "name": "Great Horned Owl",
        "id": "5459237204001"

  <p>This is the actual data used in this sample. You could include other metadata fields, but you would need to modify the script a little to send those with the first API call. You'll also notice that these are risky values to use for reference ids, especially
    for a sample like this that will be run multiple times - but I am getting around the duplication issue by appending the current epoch time in milliseconds to whatever is in the data.</p>

  <div class="form-wrapper">
    <fieldset class="bcls-fieldset">
      <legend>Inputs for Dynamic Ingest</legend>

      <p>Account: (defaults to Brightcove sample account) <input id="account_id" type="text" value="" name="account_id" /></p>

      <p>Client id: (defaults to Brightcove sample account) <input id="client_id" type="text" value="" name="client_id" /></p>

      <p>Client secret: (defaults to Brightcove sample account) <input id="client_secret" type="text" value="" name="client_secret" /></p>

      <p>Ingest profile: <select id="ingest_profile_display"></select><br /> or Custom Profile: <input id="custom_profile_display" type="text" value="" name="custom_profile_display" /> (you must use the name exactly as it appears in the Video Cloud system, or the request will fail)</p>

      <p><input id="capture_images_display" type="checkbox" checked="checked" />&nbsp;<label for="capture_images_display">Capture new images</label></p>

      <p><input id="di_Submit" class="bcls-button" type="submit" value="Start Ingest" /></p>

      <p>Full request URL for the API call:<br />
        <textarea class="bcls-code" name="url" id="di_url"></textarea> (automatically generated - for information only)</p>

<section class="bcls-section">
  <h2 id="logger">Results Log</h2>

  <pre class="line-numbers">
<code id="response" class="language-json">Response will appear here... </code></pre>
              /* * The body style is just for the
 * background color of the codepen.
 * Do not include in your code.
body {
  background-color: #111;
  color: #f5f5f5;
  font-family: sans-serif;
  margin: 2em;
 * Styles essential to the sample
 * are below
.bcls-code {
  color: #111;
  font-family: 'Source Code Pro',monospace;
  padding: 1em;
  width: 90%;
  min-height: 5em;
  background-color: #cfcfcf;
  font-size: 1rem;
.bcls-button {
  padding: .5em;
  background-color: #333;
  border: 1px yellow solid;
  border-radius: .5em;
  color: yellow;
  cursor: pointer;
fieldset {
  color: #64AAB2;
  border: 1px #64AAB2 solid;
  border-radius: .5em;
code {
  color: #E4B842;
  font-family: 'Source Code Pro',monospace;
              var BCLS = ( function (window, document) {
    var // CMS API stuff
        account_id_display = document.getElementById("account_id"),
        client_id_display = document.getElementById("client_id"),
        client_secret_display = document.getElementById("client_secret"),
        ingest_profile_display = document.getElementById("ingest_profile_display"),
        custom_profile_display = document.getElementById("custom_profile_display"),
        capture_images_display = document.getElementById('capture_images_display'),
        videoDataDisplay = document.getElementById("videoData"),
        // Dynamic Ingest API stuff
        profilesArray = ['videocloud-default-v1', 'high-resolution', 'screencast-1280', 'smart-player-transition', 'single-bitrate-high', 'audio-only', 'single-bitrate-standard'],
        di_url_display = document.getElementById("di_url"),
        di_submit_display = document.getElementById("di_Submit"),
        proxyURL = "https://solutions.brightcove.com/bcls/bcls-proxy/bcls-proxy-v2.php",
        response = document.getElementById("response"),
        videoData = [],
        totalVideos = 0,
        videoNumber = 0,
        currentJobs = 0,
        totalIngested = 0,
        defaults = {account_id: 57838016001};

    // is defined
    function isDefined(x){
        if (x === "" || x === null || x === undefined){
            return false;
        return true;

     * determines if checkbox is checked * @param  {htmlElement}  e the checkbox to check
     * @return {Boolean}  true if box is checked
    function isChecked(e) {
        if (e.checked) {
            return true;
        return false;
    // set options for the Dynamic Ingest API request
    function setDIOptions() {
        var options = {},
            body = {},
            custom_profile_display_value = custom_profile_display.value;
        // get the ingest profile
        if (isDefined(custom_profile_display_value)) {
            ingest_profile = custom_profile_display_value;
        } else {
            ingest_profile = ingest_profile_display.options[ingest_profile_display.selectedIndex].value;
        options.account_id = account_id;
        if (isDefined(client_id) && isDefined(client_secret)) {
          options.client_id = client_id;
          options.client_secret = client_secret;
        options.proxyURL = proxyURL;
        di_url_display.value = "https://ingest.api.brightcove.com/v1/accounts/" + account_id + "/videos/" + videoData[videoNumber].id + "/ingest-requests";
        body.master = {};
        body.master.use_archived_master = true;
        body.profile = ingest_profile;
        body["capture-images"] = isChecked(capture_images_display);
        options.requestBody = JSON.stringify(body);
        options.requestType = "POST";
        options.url = di_url_display.value;
        // now submit the request
        makeRequest(options, function(response) {
          var parsedData = JSON.parse(response);
          console.log('parsedData', parsedData);
          if (response.indexOf("error_code") < 0) {
              // handle the response
          logResponse("totalIngested", totalIngested);
          if (videoNumber < totalVideos) {
              logResponse('Processing video number', videoNumber + 1);
              logResponse('Current jobs: ', currentJobs + 1);
              // if currentJobs is > 99, need to pause
              if (currentJobs > 99) {
                  // reset currentJobs
                  currentJobs = 0;
                  // wait 30 min before resuming
                  t2 = setTimeout(setDIOptions, 1800000);
              } else {
          } else {
          logResponse("DI", "Request failed; retrying video number: " + videoData[videoNumber].id);
          // give api a second to rest to prevent ingest queue overrun
          t2 = setTimeout(setDIOptions, 1000);
    // function to set the request
    function logResponse(type, data) {
        response.textContent += type + ": " + data + ",\n";

     * send API request to the proxy
     * @param  {Object} options for the request
     * @param  {String} options.url the full API request URL
     * @param  {String="GET","POST","PATCH","PUT","DELETE"} requestData [options.requestType="GET"] HTTP type for the request
     * @param  {String} options.proxyURL proxyURL to send the request to
     * @param  {String} options.client_id client id for the account (default is in the proxy)
     * @param  {String} options.client_secret client secret for the account (default is in the proxy)
     * @param  {JSON} [options.requestBody] Data to be sent in the request body in the form of a JSON string
     * @param  {Function} [callback] callback function that will process the response
    function makeRequest(options, callback) {
      var httpRequest = new XMLHttpRequest(),
        proxyURL = options.proxyURL,
        // response handler
        getResponse = function() {
          try {
            if (httpRequest.readyState === 4) {
              if (httpRequest.status >= 200 && httpRequest.status < 300) {
                response = httpRequest.responseText;
                // some API requests return '{null}' for empty responses - breaks JSON.parse
                if (response === '{null}') {
                  response = null;
                // return the response
              } else {
                alert('There was a problem with the request. Request returned ' + httpRequest.status);
          } catch (e) {
            alert('Caught Exception: ' + e);
       * set up request data
       * the proxy used here takes the following request body:
       * JSON.stringify(options)
      // set response handler
      httpRequest.onreadystatechange = getResponse;
      // open the request
      httpRequest.open('POST', proxyURL);
      // set headers if there is a set header line, remove it
      // open and send request

    di_submit_display.addEventListener("click", function () {
        videoData = JSON.parse(videoDataDisplay.value);
        totalVideos = videoData.length;
        // to insure uniqueness,
        // in case of stop/start, reset videoNumber to 0
        videoNumber = 0;
        // get account inputs
        account_id = isDefined(account_id_display.value) ? account_id_display.value : defaults.account_id;
        client_id = isDefined(client_id_display.value) ? client_id_display.value : null;
        client_secret = isDefined(client_secret_display.value) ? client_secret_display.value : null;
        // set CMS API options for first video
    // initialize
    function init() {
        var i,
            iMax = profilesArray.length,
        // add options for standard ingest profiles
        for (i = 0; i < iMax; i++) {
            newOpt = new Option(profilesArray[i]);
    // call init to set things up
})(window, document);

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