|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Cloudinary Video Player - Lazy player (ESM)</title> |
| 6 | + <link |
| 7 | + href="https://res.cloudinary.com/cloudinary-marketing/image/upload/f_auto,q_auto/c_scale,w_32,e_hue:290/creative_staging/cloudinary_internal/Website/Brand%20Updates/Favicon/cloudinary_web_favicon_192x192.png" |
| 8 | + rel="icon" |
| 9 | + type="image/png" |
| 10 | + /> |
| 11 | + <link rel="icon" type="image/svg+xml" href="/vite.svg" /> |
| 12 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 13 | + </head> |
| 14 | + <body> |
| 15 | + <div class="container p-4 col-12 col-md-9 col-xl-6"> |
| 16 | + <nav class="nav mb-2"> |
| 17 | + <a href="/index.html"><< Back to examples index</a> |
| 18 | + </nav> |
| 19 | + <h1>Cloudinary Video Player</h1> |
| 20 | + <h3 class="mb-3">Lazy player (with poster URL)</h3> |
| 21 | + <p class="text-muted small mb-2">Uses an explicit <code>poster</code> URL. Custom accent color and logo configured.</p> |
| 22 | + |
| 23 | + <video |
| 24 | + id="player" |
| 25 | + playsinline |
| 26 | + controls |
| 27 | + muted |
| 28 | + class="cld-video-player cld-fluid" |
| 29 | + width="500" |
| 30 | + ></video> |
| 31 | + |
| 32 | + <button type="button" id="btn-load" class="btn btn-sm btn-outline-primary mt-2 mb-3">Load Player</button> |
| 33 | + <p class="text-muted small mb-3"> |
| 34 | + Click the player or the button above to initialize. The button calls <code>player.loadPlayer()</code>. |
| 35 | + </p> |
| 36 | + |
| 37 | + <h3 class="mt-4">Scroll to load (auto-built poster)</h3> |
| 38 | + <p class="text-muted small mb-2">No <code>poster</code> URL - built automatically from <code>cloudName</code> and <code>publicId</code>. Custom colors configured.</p> |
| 39 | + <p class="text-muted small mb-3"> |
| 40 | + Scroll down - the player loads automatically when it enters the viewport. |
| 41 | + </p> |
| 42 | + |
| 43 | + <div style="height: 80vh; display: flex; color: #aaa; font-size: 2rem;"> |
| 44 | + ↓ ↓ ↓ ↓ ↓ ↓ ↓ |
| 45 | + </div> |
| 46 | + |
| 47 | + <video |
| 48 | + id="player-scroll" |
| 49 | + playsinline |
| 50 | + controls |
| 51 | + muted |
| 52 | + loop |
| 53 | + class="cld-video-player cld-fluid" |
| 54 | + width="500" |
| 55 | + ></video> |
| 56 | + |
| 57 | + <h3 class="mt-4">Example code:</h3> |
| 58 | + <pre><code class="language-javascript"> |
| 59 | +import { player as createPlayer } from 'cloudinary-video-player/lazy'; |
| 60 | +import 'cloudinary-video-player/cld-video-player.min.css'; |
| 61 | + |
| 62 | +// With explicit poster URL |
| 63 | +const player = await createPlayer('my-video', { |
| 64 | + cloudName: 'demo', |
| 65 | + publicId: 'sea_turtle', |
| 66 | + poster: 'https://res.cloudinary.com/demo/video/upload/so_0,f_auto,q_auto/sea_turtle.jpg', |
| 67 | + lazy: true, |
| 68 | + colors: { accent: '#ff4081' } |
| 69 | +}); |
| 70 | +// await player.loadPlayer(); |
| 71 | + |
| 72 | +// Auto-built poster from cloudName + publicId |
| 73 | +createPlayer('my-video', { |
| 74 | + cloudName: 'demo', |
| 75 | + publicId: 'sea_turtle', |
| 76 | + lazy: { loadOnScroll: true }, |
| 77 | + colors: { base: '#0d1b2a', accent: '#00b4d8' } |
| 78 | +}); |
| 79 | + </code></pre> |
| 80 | + </div> |
| 81 | + |
| 82 | + <script type="module"> |
| 83 | + import { player as createPlayer } from 'cloudinary-video-player/lazy'; |
| 84 | + import 'cloudinary-video-player/cld-video-player.min.css'; |
| 85 | + |
| 86 | + (async () => { |
| 87 | + const player = await createPlayer('player', { |
| 88 | + cloudName: 'demo', |
| 89 | + publicId: 'sea_turtle', |
| 90 | + poster: 'https://res.cloudinary.com/demo/video/upload/so_0,f_auto,q_auto/sea_turtle.jpg', |
| 91 | + lazy: true, |
| 92 | + colors: { accent: '#ff4081' }, |
| 93 | + logoImageUrl: 'https://res.cloudinary.com/demo/image/upload/c_scale,w_100/cloudinary_logo.png', |
| 94 | + logoOnclickUrl: 'https://cloudinary.com' |
| 95 | + }); |
| 96 | + |
| 97 | + document.getElementById('btn-load').addEventListener('click', () => { |
| 98 | + if (player && typeof player.loadPlayer === 'function') { |
| 99 | + player.loadPlayer(); |
| 100 | + } |
| 101 | + }); |
| 102 | + |
| 103 | + createPlayer('player-scroll', { |
| 104 | + cloudName: 'demo', |
| 105 | + publicId: 'sea_turtle', |
| 106 | + lazy: { loadOnScroll: true }, |
| 107 | + colors: { base: '#0d1b2a', accent: '#00b4d8' } |
| 108 | + }); |
| 109 | + })(); |
| 110 | + </script> |
| 111 | + |
| 112 | + <link |
| 113 | + href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" |
| 114 | + rel="stylesheet" |
| 115 | + integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" |
| 116 | + crossorigin="anonymous" |
| 117 | + /> |
| 118 | + </body> |
| 119 | +</html> |
0 commit comments