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

              
                <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Cloudinary Multi Codec Adaptive Streaming</title>

<!-- Bootstrap -->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/solarized-light.min.css">
<link href="https://unpkg.com/cloudinary-video-player@edge/dist/cld-video-player.min.css" rel="stylesheet">
<link href="/style.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>



<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
    <div class="container p-4">
        <nav class="nav mb-2">
            <a href="index.html"><< Back to examples index</a>
        </nav>
        <h1 class="text-primary">Cloudinary Multi-Codec Adaptive Bitrate Streaming</h1>
        <h3 class="text-primary mb-4">Adaptive streaming</h3>
      <p>More information on the concept here: <a href="https://cloudinary.com/blog/video_optimization_part_ii_adaptive_bitrate_streaming_of_multiple_codecs" target="_blank">https://cloudinary.com/blog/video_optimization_part_ii_adaptive_bitrate_streaming_of_multiple_codecs</a></p>
        <p>The player supports adaptive streaming formats such as HLS and MPEG-DASH: <br />
          <b>HLS</b> is supported out-of-the-box and is already bundled in the player's package. <br />
          <b>MPEG-DASH</b> support can be added by including 'dash.js' and 'videojs-contrib-dash' packages (example below).<br /><br />
          Simply set 'sourceTypes' to the desired format ('dash' or 'hls'). You can define a desired streaming
          profile ('sd', 'hd', etc') using the 'transformation' param.
      <p>You'll notice a bit of logic to determine which manifest to use based on which codecs this browser supports.  The most efficient codec will automatically be chosen for you!</p>
        </p>
        <div class="video-container mb-5">
            <video
              id="example-player"
              controls
              muted
              width="680"
              height="400"
              class="cld-video-player cld-video-player-skin-dark">
            </video>
        </div>
  </div>
<!-- Cloudinary Video Player Dependencies -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/cloudinary-core/2.3.0/cloudinary-core-shrinkwrap.js"></script>
<script type="text/javascript" src="https://unpkg.com/cloudinary-video-player@edge/dist/cld-video-player.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.6.3/dash.all.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-dash/2.9.2/videojs-dash.min.js"></script>
  <!-- Actual code -->
  <script type="text/javascript">
    // var cld = cloudinary.Cloudinary.new({cloud_name: "miki-cloudinary", secure: true});
    var cld = cloudinary.Cloudinary.new({cloud_name: "demo-robert", secure: true});
function supportsVideoType(type) {
  let video;

  let formats = {
    h264: 'video/mp4; codecs="avc1.42E01E"',
    vp9: 'video/webm; codecs="vp9"',
    h265: 'video/mp4; codecs="hevc"'
  };

  if(!video) {
    video = document.createElement('video')
  }

  return video.canPlayType(formats[type] || type);
}

if(supportsVideoType('h265') === "probably" || supportsVideoType('h265') === "maybe") {
  var videoManifest = 'hls',
  videoCodec = 'h265';
}
else if(supportsVideoType('vp9') === "probably") {
  var videoManifest = 'dash',
  videoCodec = 'vp9';
}
else {
  var videoManifest = 'hls',
  videoCodec = 'h264';
}
  var demoplayer = cld.videoPlayer('example-player', {
      publicId: 'ouch',
      fluid: true,
      loop: false,
      controls: true,
      autoplayMode: 'never',
      transformation: {streaming_profile:'16x9_'+videoCodec+'_text2'},
      sourceTypes: [videoManifest]
  })

    // playerMp4.source('videos/product-care/Store_Your_Parka_-_EN_MASTER_NO_FAQLINK-', { sourceTypes: ["hls", "mp4", "webm"] }).play();
    // playerDash.source('oceans', { sourceTypes: ['dash'], transformation: { streaming_profile: 'hd' }, info: { title: "MPEG-DASH" } }).play();
  </script>
</body>
</html>



              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console