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.


    <link href="" rel="stylesheet">
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>

    <div class="video-container">
        <form class="src-container-direct">
            <input class="src-input" placeholder="Enter .m3u8" />
            <button class="src-submit" type="submit">Load</button>
        <video id="amazon-ivs-videojs" class="video-js vjs-4-3 vjs-big-play-centered" controls autoplay playsinline>


                body {
    margin: 0;

.src-container-direct {
    margin-bottom: 15px;
    text-align: center;

    input {
        padding: 10px 5px;
        width: 186px;

    .customer-id-input {
        margin-right: 10px;

    .src-input {
        width: 400px;

.src-submit {
    height: 37px;
    border-color: #ddd;
    margin: 1px 5px;

.video-container {
    width: 640px;
    height: 480px;
    margin: 15px;

/* Align the quality menu to right side of video container */
.video-js .vjs-menu-button-popup .vjs-menu {
    left: auto;
    right: 0;



                const DEFAULT_STREAM =

// Initialize player
(function () {
    // Set up IVS playback tech and quality plugin

    // Initialize video.js player
    const videoJSPlayer = videojs("amazon-ivs-videojs", {
        techOrder: ["AmazonIVS"],
        controlBar: {
            playToggle: {
                replay: false
            }, // Hides the replay button for VOD
            pictureInPictureToggle: false // Hides the PiP button

    // Use the player API once the player instance's ready callback is fired
    const readyCallback = function () {
        // This executes after video.js is initialized and ready
        window.videoJSPlayer = videoJSPlayer;

        // Get reference to Amazon IVS player
        const ivsPlayer = videoJSPlayer.getIVSPlayer();

        // Show the "big play" button when the stream is paused
        const videoContainerEl = document.querySelector("#amazon-ivs-videojs");
        videoContainerEl.addEventListener("click", () => {
            if (videoJSPlayer.paused()) {
            } else {

        // Logs low latency setting and latency value 5s after playback starts
        const PlayerState = videoJSPlayer.getIVSEvents().PlayerState;
        ivsPlayer.addEventListener(PlayerState.PLAYING, () => {
            console.log("Player State - PLAYING");
            setTimeout(() => {
                    `This stream is ${
                        ivsPlayer.isLiveLowLatency() ? "" : "not "
                    }playing in ultra low latency mode`
                console.log(`Stream Latency: ${ivsPlayer.getLiveLatency()}s`);
            }, 5000);

        // Log errors
        const PlayerEventType = videoJSPlayer.getIVSEvents().PlayerEventType;
        ivsPlayer.addEventListener(PlayerEventType.ERROR, (type, source) => {
            console.warn("Player Event - ERROR: ", type, source);

        // Log and display timed metadata
        ivsPlayer.addEventListener(PlayerEventType.TEXT_METADATA_CUE, (cue) => {
            const metadataText = cue.text;
            const position = ivsPlayer.getPosition().toFixed(2);
                `Player Event - TEXT_METADATA_CUE: "${metadataText}". Observed ${position}s after playback started.`

        // Enables manual quality selection plugin

        // Set volume and play default stream

    // Register ready callback

// Sets up input box for Amazon IVS manifest
(function () {
    const containerEl = document.querySelector(".video-container");
    const directSrcFormEl = containerEl.querySelector(".src-container-direct");
    const directSrcInputEl = containerEl.querySelector(".src-input");
    directSrcFormEl.addEventListener("submit", (e) => {