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

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.

HTML

              
                <p>Work in Progress. Press <strong>Play</strong> first.</p>

<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/72199688&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>

<div class="wavesurfer-transcript">
  <p><span class="wavesurfer-marker" data-start="0" data-end="5">Alien 2347</span></p>
    <p><span class="wavesurfer-marker" data-start="5" data-end="8">Episode numero 1</span></p>
  <p><span class="wavesurfer-marker" data-start="8" data-end="11.5">Dans le vaisseau A2347,</span> <span class="wavesurfer-marker" data-start="11.5" data-end="15.5">d'étranges extraterrestres complotent secrètement.</span></p>
</div>
              
            
!

CSS

              
                .wavesurfer-marker:hover {
  cursor: pointer;
  text-decoration: underline;
}

.wavesurfer-marker-current {
  background: rgba(126, 126, 126, 0.4);
}
              
            
!

JS

              
                // Sample Markers on Page
var MarkersInit = function(markers) {
  var elements = document.querySelectorAll('.wavesurfer-marker');
  Array.prototype.forEach.call(elements, function(el, i) {
    var time_start = el.dataset.start;
    var time_end = el.dataset.end;
    var id = el.dataset.id;;
    if (id >= 1) {
      id = id - 1;
    } else {
      id = 0;
    }
    marker = {};
    marker.time_start = time_start;
    marker.time_end = time_end;
    marker.dom = el;
    if (typeof(markers[id]) === 'undefined') {
      markers[id] = [];
    }
    markers[id].push(marker);
  });
}

// On Ready
document.onreadystatechange = () => {
  if (document.readyState === 'complete') {

    // Init Markers
    var markers = [];
    MarkersInit(markers);

    // Create SoundCloud Player Object ( TODO: all loop)
    var iframeElement = document.querySelector("iframe");
    var widget = SC.Widget(iframeElement);

    // Register On Click Event Handler
    var elements = document.querySelectorAll('.wavesurfer-marker');
    Array.prototype.forEach.call(elements, function(el, i) {
      el.onclick = function() {
        // Get Data Attribute
        var pos = el.dataset.start * 1000;
        // Seek
        widget.seekTo(pos);
      }
    });

    // Bind Continuous Play
    widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
      widget.getPosition(function(current_time) {
        current_time = current_time / 1000;
        var j = 0; // NOTE: to extend for several players
        markers[j].forEach(function(marker, i) {
          if (current_time >= marker.time_start && current_time <= marker.time_end) {
            marker.dom.classList.add("wavesurfer-marker-current");
          } else {
            marker.dom.classList.remove("wavesurfer-marker-current");
          }
        });
      });
    });

  } // Document Complete
}; // Document Ready State Change
              
            
!
999px

Console