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.

              <!-- ideally this should be in <head> -->  
<script src="//cdn.viblast.com/vb/stable/viblast.js"></script>

<!-- body -->
  <button onclick="load('http://cdn3.viblast.com/streams/hls/airshow/playlist.m3u8');" type="button">Load HLS Stream</button>
  <button onclick="load('http://dash.edgesuite.net/dash264/TestCases/3b/fraunhofer/heaac_stereo_with_video/Sintel/sintel_480p_heaac_stereo_sidx.mpd');" type="button">Load MPEG-DASH Stream</button>

<video id="player" controls muted>

<div class="quality-controls">
Available Video Qualities:
<select id="video-qualities" onchange="changeQuality(this, 'video');">
  <option value="NA">NA</option>

Current Quality: <span id="current-video-quality">NA</span>

<div class="quality-controls">
Available Audio Qualities:
<select id="audio-qualities" onchange="changeQuality(this, 'audio');">
  <option value="NA">NA</option>

Current Quality: <span id="current-audio-quality">NA</span>

  Current CDN Bandwidth:
  <span id="cdn-bandwidth">NA</span>
  <span class="note">Beware that due to caching values much higher than the actual bandwidth may be reported</span>
              video { height: 200px; width: auto; }
.quality-controls { margin-bottom: 0.5em; }
.note { color: gray; padding-left: 1em; }
              var player = document.getElementById('player');

function formatQuality(quality) {
  var res = '';
  if (quality.width && quality.height) {
    res += quality.width + 'x' + quality.height + ' ';
  res += quality.bandwidth + 'bps';
  return res;

function changeQuality(control, channel) {
  var selectedQuality = control.value;
  if (selectedQuality === "auto") {
    player.viblast.abr = true;
  } else {
    player.viblast[channel].quality = player.viblast[channel].qualities[parseInt(selectedQuality)];

function onUpdatedMetadata() {

function refreshAvailableQualities(channel) {
  var qualitiesControl = document.getElementById(channel + '-qualities');
  qualitiesControl.innerHTML = '';
  qualitiesControl.innerHTML += '<option value="auto">Auto</option>'
  for (var i = 0; i<player.viblast[channel].qualities.length; i++) {
    var quality = player.viblast[channel].qualities[i];
    qualitiesControl.innerHTML += '<option value="' + i + '">'  + formatQuality(quality) + '</option>';

function refreshQuality(channel) {
  if (!player.viblast[channel] || !player.viblast[channel].quality) return;
  var currQualityControl = document.getElementById('current-' + channel + '-quality');
  currQualityControl.innerHTML = formatQuality(player.viblast[channel].quality);

function load(src) {
  // clean up any old instances
  // start playing the new stream
    stream: src,
    key: 'N8FjNTQ3NDdhZqZhNGI5NWU5ZTI='
  // register the updatedmetadata each time because after src change event hanlers are cleared
  player.viblast.addEventListener('updatedmetadata', onUpdatedMetadata);
  // check if metadata has already been loaded
  // if yes then updatedmetadata will not be fired so just call the callback manually
  if (player.viblast.video) onUpdatedMetadata();
  player.viblast.addEventListener('videoqualitychange', refreshQuality.bind(null, 'video'));
  player.viblast.addEventListener('audioqualitychange', refreshQuality.bind(null, 'audio'));

window.setInterval(function() {
  var control = document.getElementById('cdn-bandwidth');
  if (player.viblast) {
    control.innerHTML = player.viblast.cdnBandwidth + 'kbps';
  } else {
    control.innerHTML = 'NA';
}, 1000);
🕑 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.