Codepen - Jw Player
<div class="footer-note"> <span><i class="fab fa-js"></i> JW Player API integration · Dynamic controls</span> <span><i class="fas fa-codepen"></i> Inspired by CodePen "Feature" concept — fully responsive</span> <span><i class="fas fa-ad"></i> Demo preroll ad (5s skip after 2s) | Video: Big Buck Bunny (CC)</span> </div> </div>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <title>JW Player CodePen Showcase | Interactive Video Player Demo</title> <!-- JW Player CDN (v8 core + premium skin) --> <script src="https://cdn.jwplayer.com/libraries/6m8y8a1Z.js"></script> <!-- Google Fonts for modern typography --> <link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700&display=swap" rel="stylesheet"> <!-- Font Awesome 6 (free icons) --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <style> * margin: 0; padding: 0; box-sizing: border-box;
playerInstance.on('play', function() logEvent('Playback started'); ); playerInstance.on('pause', function() logEvent('Playback paused'); ); playerInstance.on('adStarted', function(ad) logEvent(`Ad started: $`); // Show in console and optional small alert style const statusDiv = document.querySelector('.status-indicator'); if (statusDiv) statusDiv.innerHTML = '<i class="fas fa-ad" style="color:#f97316;"></i> Ad playing — sponsored content'; setTimeout(() => if (playerInstance && !playerInstance.getAdBlock()) if (statusDiv && !playerInstance.getState() === 'advertising') statusDiv.innerHTML = '<i class="fas fa-check-circle" style="color:#22c55e;"></i> Player ready · HLS + Ads active'; , 3000); ); playerInstance.on('adFinished', function() logEvent('Ad finished, resuming content'); const statusDiv = document.querySelector('.status-indicator'); if (statusDiv) statusDiv.innerHTML = '<i class="fas fa-check-circle" style="color:#22c55e;"></i> Player ready · HLS + Ads active'; ); playerInstance.on('error', function(e) console.warn('Player error: ', e); ); } jw player codepen
.quality-badge display: inline-block; background: #e6f0ff; padding: 0.25rem 0.8rem; border-radius: 30px; font-size: 0.75rem; font-weight: 600; margin-left: 8px; color: #075985;
// Event listeners to show interactivity playerInstance.on('ready', function() logEvent('Player ready and loaded'); // Optionally update status const statusDiv = document.querySelector('.status-indicator'); if (statusDiv) statusDiv.innerHTML = '<i class="fas fa-check-circle" style="color:#22c55e;"></i> Player ready · HLS + Ads active'; ); i class="fab fa-js">
<div class="codepen-container"> <!-- Header reminiscent of CodePen embed style --> <div class="pen-header"> <div class="pen-logo"> <i class="fab fa-codepen"></i> <span>JW Player · Interactive Demo</span> </div> <div class="pen-badge"> <i class="fas fa-play-circle"></i> LIVE PREVIEW · JW v8.22 </div> </div>
.player-area flex: 2; min-width: 280px; background: #000000; padding: 2rem 1.5rem 1.8rem 1.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; i class="fas fa-codepen">
// Optional: set license key (demo uses free key from cdn, but we can use generic) // jwplayer.key = "YOUR_DEMO_KEY"; // not required for our demo streams // Create player playerInstance = jwplayer(containerId).setup({ // Playlist: one media item with HLS fallback + mp4 for broad compatibility playlist: [ title: "Big Buck Bunny - 4K Teaser", description: "Open source movie demo ], // Advertising: VAST tag demo (preroll ad from JW ad inventory demo) advertising: client: "vast", schedule: "myAdRule": "offset": "pre", "tag": "https://cdn.jwplayer.com/tags/6m8y8a1Z/pre.xml" , // optional: skip message skipoffset: 2, // skip after 2 seconds if allowed skipmessage: "Ad: Skip in xx secs" , width: "100%", aspectratio: "16:9", primary: "html5", autostart: false, // autostart off, user can click play mute: false, controls: true, skin: name: "seven" // modern default skin , playbackRateControls: [0.75, 1, 1.25, 1.5, 2], // additional config sharing: heading: "Share this video", link: "https://example.com/jwplayer-demo" , cast: {} // enable chromecast if available });
