-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add responsive breakpoints #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
664c169
feat: add responsive breakpoints
mizadi 1ee5532
fix: add tests
mizadi 75100fd
fix: test
mizadi ad4d44b
fix: tests
mizadi 234bacb
fix: raw url test
mizadi 328648b
fix: code styling
mizadi 2b9f0d0
fix: revert package.json
mizadi d672c23
fix: e2e test
mizadi 9370bf8
fix: unit test
mizadi ae86615
fix: dpr and redenition issues
mizadi a33cdef
fix: simpilify dpr vlaidation
mizadi d24764b
fix: breakpoints tests + getters and setters
mizadi 31eb8e2
fix: code styling
mizadi 814c32c
fix: add player width validation
mizadi 93346f6
fix: remove dpr validation
mizadi 28c8efa
fix: add breakpoints and dpr to validators
mizadi bc33ec2
fix: remove breakpoitns getters and setters
mizadi 137b30c
fix: move logic to plugin
mizadi 32262a2
fix: simplify code
mizadi 885d2e3
fix: remove whitespace
mizadi eb8e80d
fix: remove whitespace
mizadi aaca893
fix: revert posterOptionsForCurrent
mizadi 30477d3
fix: revert posterOptionsForCurrent
mizadi fc895c4
fix: lint error
mizadi 948e09f
fix: remove redundant code
mizadi 00671a4
fix: move player element into breakpoints
mizadi c7bd562
chore: add internal analytics
mizadi 24f1263
fix: breakpoints sample page
mizadi afd1ad5
fix: breakpoints sample page
mizadi 151884a
chore: add dpr to internal analytics
mizadi a0c37f0
fix: remove redundant code
mizadi fee54c4
feat: add 2560 rendition
mizadi 6f7d0c6
feat: add 848 rendition
mizadi 474832b
fix: breakpoints calculation logic
mizadi b2264c4
fix: remove redundant tests
mizadi 3f32cfd
fix: remove redundant tests
mizadi 0abd97b
fix: test description
mizadi 67c2411
chore: add dpr tests
mizadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>Breakpoints - Cloudinary Video Player</title> | ||
| <link href="https://res.cloudinary.com/cloudinary-marketing/image/upload/f_auto,q_auto/c_scale,w_32/v1597183771/creative_staging/cloudinary_internal/Website/Brand%20Updates/Favicon/cloudinary_web_favicon_192x192.png" rel="icon" type="image/png"> | ||
|
|
||
| <!-- Bootstrap --> | ||
| <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | ||
|
|
||
| <script type="text/javascript" src="scripts.js"></script> | ||
|
|
||
| <style> | ||
| .player-container { | ||
| margin-bottom: 30px; | ||
| } | ||
| .video-url { | ||
| margin-top: 15px; | ||
| padding: 10px; | ||
| background: #f8f9fa; | ||
| border-radius: 5px; | ||
| word-break: break-all; | ||
| font-family: monospace; | ||
| font-size: 12px; | ||
| } | ||
| </style> | ||
|
|
||
| <script type="text/javascript"> | ||
| window.addEventListener('load', function(){ | ||
|
|
||
| const player = cloudinary.videoPlayer('player-with-breakpoints', { | ||
| cloudName: 'demo', | ||
| breakpoints: true, | ||
| dpr: 2.0 | ||
| }); | ||
| player.source('sea_turtle'); | ||
|
|
||
| // Display video URL using multiple methods | ||
| function updateVideoUrl() { | ||
| // Try getting from video element | ||
| const videoElement = player.videojs?.el()?.querySelector('video') || | ||
| document.querySelector('#player-with-breakpoints video') || | ||
| document.querySelector('.vjs-tech'); | ||
|
|
||
| const src = videoElement?.currentSrc || videoElement?.src || ''; | ||
|
|
||
| if (src) { | ||
| document.getElementById('video-url').textContent = src; | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // Update URL when video source is loaded | ||
| player.on('loadedmetadata', updateVideoUrl); | ||
|
|
||
| }, false); | ||
| </script> | ||
|
|
||
| </head> | ||
| <body> | ||
|
|
||
| <div class="container p-4"> | ||
| <h1 class="mb-4">Breakpoints - Responsive Video Resolution</h1> | ||
|
|
||
| <p class="lead"> | ||
| Breakpoints automatically select the optimal video resolution based on container width and device pixel ratio (DPR). | ||
| </p> | ||
|
|
||
| <div class="player-container"> | ||
| <h3>Breakpoints Example (DPR 2.0)</h3> | ||
| <p>The player automatically rounds container width to the nearest rendition [640, 1280, 1920, 3840] and lets Cloudinary handle DPR scaling.</p> | ||
|
|
||
| <video | ||
| id="player-with-breakpoints" | ||
| controls | ||
| muted | ||
| class="cld-video-player cld-video-player-skin-dark cld-fluid"> | ||
| </video> | ||
|
|
||
| <div class="video-url mt-3"> | ||
| <strong>Video URL:</strong><br> | ||
| <span id="video-url">Loading...</span> | ||
| </div> | ||
|
|
||
| <details class="mt-3"> | ||
| <summary><strong>View Code</strong></summary> | ||
| <pre><code>const player = cloudinary.videoPlayer('player', { | ||
| cloudName: 'demo', | ||
| breakpoints: true, | ||
| dpr: 2.0 | ||
| }); | ||
|
|
||
| player.source('sea_turtle');</code></pre> | ||
| </details> | ||
| </div> | ||
|
|
||
| <h3 class="mt-5">Configuration Options</h3> | ||
| <ul> | ||
| <li><code>breakpoints</code> (boolean): Enable/disable breakpoints</li> | ||
| <li><code>dpr</code> (number): Device pixel ratio - 1.0, 1.5, or 2.0 (default: 2.0)</li> | ||
| <li><strong>Renditions:</strong> [640, 1280, 1920, 3840] - Container width is rounded to nearest value</li> | ||
| </ul> | ||
|
|
||
| <p class="mt-4"> | ||
| <a href="./index.html">← Back to Examples</a> | ||
| </p> | ||
|
|
||
| </div> | ||
|
|
||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Breakpoints - Cloudinary Video Player</title> | ||
| <link | ||
| 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" | ||
| rel="icon" | ||
| type="image/png" | ||
| /> | ||
| <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <style> | ||
| .player-container { | ||
| margin-bottom: 30px; | ||
| } | ||
| .video-url { | ||
| margin-top: 15px; | ||
| padding: 10px; | ||
| background: #f8f9fa; | ||
| border-radius: 5px; | ||
| word-break: break-all; | ||
| font-family: monospace; | ||
| font-size: 12px; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div class="container p-4 col-12 col-md-9 col-xl-6"> | ||
| <nav class="nav mb-2"> | ||
| <a href="/index.html"><< Back to examples index</a> | ||
| </nav> | ||
| <h1>Cloudinary Video Player</h1> | ||
| <h3 class="mb-4">Breakpoints - Responsive Video Resolution</h3> | ||
|
|
||
| <p> | ||
| Breakpoints automatically select the optimal video resolution based on player width and device pixel ratio (DPR). | ||
| Container width is rounded to the nearest rendition [640, 1280, 1920, 3840] and Cloudinary handles DPR scaling. | ||
| </p> | ||
|
|
||
| <div class="player-container"> | ||
| <h4 class="mt-4">Breakpoints Example (DPR 2.0)</h4> | ||
| <video | ||
| id="player-with-breakpoints" | ||
| class="cld-video-player" | ||
| controls | ||
| muted | ||
| width="500" | ||
| ></video> | ||
|
|
||
| <div class="video-url"> | ||
| <strong>Video URL:</strong><br> | ||
| <span id="video-url">Loading...</span> | ||
| </div> | ||
| </div> | ||
|
|
||
| <h4 class="mt-4">Configuration</h4> | ||
| <ul> | ||
| <li><code>breakpoints</code> (boolean): Enable/disable breakpoints</li> | ||
| <li><code>dpr</code> (number): Device pixel ratio - 1.0, 1.5, or 2.0 (default: 2.0)</li> | ||
| <li><strong>Renditions:</strong> [640, 1280, 1920, 3840]</li> | ||
| </ul> | ||
|
|
||
| <p class="mt-4"> | ||
| <a href="https://cloudinary.com/documentation/cloudinary_video_player" | ||
| >Full documentation</a | ||
| > | ||
| </p> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import videoPlayer from 'cloudinary-video-player/videoPlayer'; | ||
| import 'cloudinary-video-player/cld-video-player.min.css'; | ||
|
|
||
| const player = videoPlayer('player-with-breakpoints', { | ||
| cloudName: 'demo', | ||
| breakpoints: true, | ||
| dpr: 2.0 | ||
| }); | ||
| player.source('sea_turtle'); | ||
|
|
||
| // Display video URL using multiple methods | ||
| function updateVideoUrl() { | ||
| // Try getting from video element | ||
| const videoElement = player.videojs?.el()?.querySelector('video') || | ||
| document.querySelector('#player-with-breakpoints video') || | ||
| document.querySelector('.vjs-tech'); | ||
|
|
||
| const src = videoElement?.currentSrc || videoElement?.src || ''; | ||
|
|
||
| if (src) { | ||
| document.getElementById('video-url').textContent = src; | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // Update URL when video source is loaded | ||
| player.on('loadedmetadata', updateVideoUrl); | ||
| </script> | ||
|
|
||
| <!-- Bootstrap --> | ||
| <link | ||
| href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" | ||
| rel="stylesheet" | ||
| integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" | ||
| crossorigin="anonymous" | ||
| /> | ||
| </body> | ||
| </html> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.