Pen Settings



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


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.


                <!-- ideally this should be in <head> -->  
<script src="//"></script>

<!-- body -->
  <button onclick="load('//');" type="button">Load HLS Stream</button>
  <button onclick="load('//');" 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 ( 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);