Skip to content

Commit

Permalink
Add highest bitrate - wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Satya Deep Maheshwari committed Feb 24, 2025
1 parent 20bcf16 commit b5216e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/aem-assets-plugin/blocks/video/video.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ main>.section.video-container {
overflow: hidden;
background-color: #53565a;
width: 100%;
height: calc(100vh - var(--nav-height));
height: 2160px;
}

.video-hero .video-hero-content {
Expand Down
18 changes: 17 additions & 1 deletion plugins/aem-assets-plugin/blocks/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function getDeviceSpecificVideoUrl(videoUrl, isProgressive) {
function parseConfig(block) {
const isAutoPlay = block.classList.contains('autoplay');
const isProgressive = block.classList.contains('progressive');

const isHighestBitrate = block.classList.contains('highestbitrate');
if (block.classList.contains('hero')) {
const posterImage = block.querySelector('picture');
const videoUrl = block.querySelector('div > div:first-child a').href;
Expand All @@ -36,6 +36,7 @@ function parseConfig(block) {
description,
button,
posterImage,
highestBitrate: isHighestBitrate,
};
}

Expand All @@ -52,12 +53,14 @@ function parseConfig(block) {
title,
description,
posterImage,
highestBitrate: isHighestBitrate,
};
});

return {
type: 'cards',
cards,
highestBitrate: isHighestBitrate,
};
}

Expand All @@ -68,6 +71,7 @@ function parseConfig(block) {
type: 'modal',
videoUrl: getDeviceSpecificVideoUrl(videoUrl, isProgressive),
posterImage,
highestBitrate: isHighestBitrate,
};
}

Expand Down Expand Up @@ -277,6 +281,16 @@ function setupPlayer(url, videoContainer, config) {
vhs: {
useDevicePixelRatio: true,
customPixelRatio: window.devicePixelRatio ?? 1,
// Start with highest quality for highestbitrate class
limitRenditionByPlayerDimensions: !config.highestBitrate,
// Select highest bitrate variant
selectionCallback: config.highestBitrate
? (playlistController, representations) => representations.reduce((highest, current) => (
(!highest || current.bandwidth > highest.bandwidth)
? current
: highest
))
: undefined,
},
};

Expand Down Expand Up @@ -365,6 +379,7 @@ async function decorateVideoCard(container, config) {
fill: true,
posterImage: config.posterImage,
progressive: config.progressive,
highestBitrate: config.highestBitrate,
});
}

Expand Down Expand Up @@ -405,6 +420,7 @@ async function decorateHeroBlock(block, config) {
fill: true,
posterImage: config.posterImage,
progressive: config.progressive,
highestBitrate: config.highestBitrate,
});
}

Expand Down

0 comments on commit b5216e9

Please sign in to comment.