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


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.


                <h1>Basic playlist</h1>
<p>Just select any of the options in the dropdown and see how the player changes the source</p>
<p>Works for both video and audio!</p>

<p>If you like this Pen, please show your support to this project by giving it a star by clicking in the icon below.</p>
<a class="github-button" href="" data-size="large" data-show-count="true" aria-label="Star openplayerjs/openplayerjs on GitHub">Star</a>

<div class="players video-player">
  <video class="op-player__media" id="video" controls playsinline>
    <source src="" type="video/mp4"></video>
  <select name="sources">
    <option value="" selected>MP4</option>
    <option value="">WebM</option>
    <option value="">HLS</option>
    <option value="">M(PEG)-DASH</option>
<p><strong>Note:</strong> For the live HLS audio, it requires a custom method to parse the content and display the data associated</p>
<div class="players audio-player">
  <div id="stream-info" class="hidden"></div>
  <audio class="op-player__media" id="audio" controls>
    <source src="" type="audio/mp3">
  <select name="sources">
    <option value="" selected>MP3</option>
    <option value="">HLS</option>


                select {
  margin-top: 20px;
select:last-child {
  margin-bottom: 20px;
#stream-info {
  min-height: 300px;
#stream-info.hidden {
  min-height: 0;
#stream-info > img {
  float: left;
  width: 300px;
#stream-info > p {
  margin-left: 315px;
.op-controls__test > img {
  max-height: 18px;


                function loadMedia(e) {
  const id ='.players').querySelector('.op-player').id;
  const player = OpenPlayerJS.instances[id];
  player.src = this.value.replace('&amp;', '&');
  setTimeout(() => {
  }, 250);

function extractMeta(data, audio) {
  let startLoc;
  let endLoc;

  // name
  startLoc = data.indexOf("TRSN") + 11;
  endLoc = data.indexOf("TRSO");
  const name = data.substring(startLoc, endLoc);

  // desc
  startLoc = data.indexOf("TRSO") + 11;
  endLoc = data.indexOf("TIT2");
  const desc = data.substring(startLoc, endLoc);

  // artist
  startLoc = data.indexOf("TPE1") + 11;
  endLoc = data.indexOf("TPE2");
  const artist = data.substring(startLoc, endLoc);

  // title
  startLoc = data.indexOf("TIT2") + 11;
  endLoc = data.indexOf("TPE1");
  const title = data.substring(startLoc, endLoc);

  // image
  const image = data.match('(http:\/\/|https:\/\/).*\.(jpg|png|svg)')[0];
  const infoArea = document.getElementById('stream-info');

  infoArea.innerHTML = `
    <img src="${image}" alt="${title}, by ${artist}" width="300" />
    <p>Name: ${name}</p>
    <p>Desc: ${desc}</p>
    <p>Artist: ${artist}</p>
    <p>Title: ${title}</p>
  audio.poster = image;

document.querySelectorAll('select[name=sources]').forEach(source => {
  source.addEventListener('change', loadMedia);

document.querySelectorAll('.op-player__media').forEach((player, i) => {
  const p = new OpenPlayerJS(, {
    hls: {
      startLevel: -1
  if (i === 1) {
    p.getElement().addEventListener('hlsFragParsingMetadata', event => {
        const parsedTag = [];
        event.detail.samples[0].data.forEach(element => {
        extractMeta(parsedTag.toString().replace(/,/g, ''), p.getElement());