Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Graphic SDK - Local Preview</title>
  <link href="https://fonts.googleapis.com/css?family=Arimo" rel="stylesheet">
  <!-- Include the Singular Graphics SDK JavaSrcipt library -->
  <script src="https://app.singular.live/libs/singulargraphics/1.0.0/singulargraphics.js"></script>
</head>

<body>

  <!-- load Singular Player into iFrame -->
  <table style='width:480px;'>
    <tr>
      <td>
        <table>
          <tr>
            <td>Token</td>
            <td><input type="text" id='id-app-token' placeholder="Enter app token" size="30" value="09oKJJK3wTTUcA3dOwWV7A"></input> </td>
          </tr>
          <tr>
            <td></td>
            <td>
              <button type="button" onclick="loadCompositionClick()">Load Composition URL from App Token</button>
            </td>
          </tr>
        </table>
      </td>

    </tr>
    <tr>
      <td>
        <iframe id="SingularOverlay" style='width:480px; height: 300px; border: solid 1px black' src="https://app.singular.live/singularplayer/client"></iframe>
      </td>
    </tr>
    <tr>
      <td>
        <table>
          <tr>
            <td></td>
            <td>LowerThird</td>
          </tr>
          <tr>
            <td>Text</td>
            <td><textarea id='id-text' placeholder="Enter text" rows="1" cols="40"></textarea> </td>
          </tr>
          <tr>
            <td>Ctrl</td>
            <td>
              <button type="button" onclick="updateMainTitleClick()">Update</button>
              <button type="button" onclick="animationToClick('In')">Anim In</button>
              <button type="button" onclick="animationToClick('Out')">Anim Out</button>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

  <div id='id-status'>Status: </div>

</body>

</html>
              
            
!

CSS

              
                body {
  background-color: #f4f4f6;
  font-family: font-family "Roboto", sans-serif;
  font: normal 100%/1.4 sans-serif;
  color: #515477;
  overflow-x: hidden;
}

h1,
p {
  text-align: left;
}

table,
tr {
  border: 1px solid black;
  align-items: stretch;
  white-space: nowrap;
  width: 100%;
}

              
            
!

JS

              
                let overlay = undefined;
let elStatus = undefined;
let elTitle = undefined;
let elAppToken = undefined;
let compMain = undefined;
let compLower = undefined;
const subcompName = "Lower - Header";

/*****************************************************************************/
window.onload = (event) => {
  console.log("The page has fully loaded");
  elStatus = document.querySelector("#id-status");
  elTitle = document.querySelector("#id-text");
  elAppToken = document.querySelector("#id-app-token");
  overlay = SingularGraphics("SingularOverlay");
  overlay.addListener("error", function (event, msg) {
    if (event == "error") {
      elStatus.innerHTML = msg.error.message;
    }
  });

  // load composition on loading
  loadCompositionClick();
};

/*****************************************************************************/
// Locate the output token:
//                                  v--------------------v
// https://app.singular.live/output/1zdbRyB0atQxufS6d29zTH/Output?aspect=16:9
// https://app.singular.live/output/2U5mNKpvLqD4mTKyrIWbmS/Output?aspect=16:9
//
// we use the app token in this example:
// app token: 56BEDC916QbVwyY4be5L8q
function renderAppOutput(token) {
  overlay.renderAppOutput(token, undefined, (isSuccess) => {
    elStatus.innerHTML =
      "INFO: Loading app instance output: " + JSON.stringify(isSuccess);
    console.log(
      "INFO: Loading app instance output: " + JSON.stringify(isSuccess)
    );
    getCompositionReferences();
    clearOutput();
  });
}

/*****************************************************************************/
// Load composition token into Singular preview player
function loadCompositionUrl(compositionUrl) {
  overlay.loadComposition(compositionUrl, (isSuccess) => {
    elStatus.innerHTML =
      "INFO: Loading app instance output: " + JSON.stringify(isSuccess);
    console.log(
      "INFO: Loading app instance output: " + JSON.stringify(isSuccess)
    );
    getCompositionReferences();
    clearOutput();
  });
}

/*****************************************************************************/
// clearOutput
const getCompositionReferences = function () {
  compMain = overlay.getMainComposition();
  // get reference to subcomposition and play In animation
  compLower = compMain.find(subcompName)[0];
  compLower.playTo("In");
};
/*****************************************************************************/
// clearOutput
const clearOutput = function () {
  compMain.listSubcompositions().forEach((comp) => {
    compMain.getSubcompositionById(comp.id).jumpTo("Out");
    // alternatively use playTo(toState) to play to the defined animation state
    // compMain.getSubcompositionById(comp.id).playTo("Out");
  });
};
/*****************************************************************************/
// loadCompositionClick
const loadCompositionClick = function () {
  const appToken = elAppToken.value;
  const apiURL = "https://app.overlays.uno/apiv2/controlapps/" + appToken;
  const requestOptions = {
    method: "GET",
    redirect: "follow"
  };
  fetch(apiURL, requestOptions)
    .then((response) => response.json())
    .then((result) => {
      console.log(result);
      loadCompositionUrl(result.compositionJson);
    })
    .catch((error) => console.log("error", error));
};
/*****************************************************************************/
// set content
const updateMainTitleClick = function () {
  compLower.setPayload({ Header: elTitle.value });
};

/*****************************************************************************/
// run animation
const animationToClick = function (toState) {
  compLower.playTo(toState);
};

/*****************************************************************************/

              
            
!
999px

Console