Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div id="sdnPlayer"></div>

<script src="//player.3qsdn.com/js3q.latest.js"></script>

              
            
!

CSS

              
                body {
  margin: 0 auto;
  max-width: 50rem;
  background: #eee;
}
              
            
!

JS

              
                const dataId_main = '66e68995-11ca-11e8-9273-002590c750be'
const dataId_second = '1bc8cbdc-73c5-11e8-ae4b-0cc47a188158'

let player

// Main method to set up the player
const loadPlayer = (dataId) => {
  // Destroy the existing player
  if (player && typeof player.destroy === 'function') {
    player.destroy()
  }
  
  // Initialize the player
  player  = new js3q({
    container: 'sdnPlayer',
    dataid: dataId,
    controlBarAutoHide: false,
  })
  
  player.on('media.ready', () => {
    // Set the dataid to the opposite of the current
    const nextDataId = dataId === dataId_main ? dataId_second : dataId_main
    
    attachButton(nextDataId)
  })
}

// Create the Button and attach it to the ControlBar
function attachButton(dataid) {
  // If there is already a button, skip
  if (document.getElementById('sdnPlayer-switch-button')) return

  // Define the button
  const switchBtnEl = document.createElement('js3q-button')
  switchBtnEl.setAttribute('id', 'sdnPlayer-switch-button')
  switchBtnEl.setAttribute('class', 'sdn-button-right sdnicbsun-chat')
  switchBtnEl.setAttribute('tooltip', 'Switch language')
  switchBtnEl.addEventListener('click', () => loadPlayer(dataid))

  // Attach the button to the control bar
  const controlbarEl = document.getElementById('sdnPlayer-chrome')
  controlbarEl.appendChild(switchBtnEl)  
}

// Initial Call
loadPlayer(dataId_main)
              
            
!
999px

Console