Skip to content
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

Zoom icons 596 #619

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/app.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
html {
font-size: 16px;
font-size: 1em;
font-family: Arial, Helvetica, sans-serif;
}

Expand All @@ -25,14 +25,14 @@ html {
}

.ramp-demo__manifest-input-label {
padding: 12px 12px 12px 0;
padding: 0.75em 0.75em 0.75em 0;
display: inline-block;
}

.ramp-demo__manifest-submit {
background-color: #2a5459;
color: white;
padding: 12px 20px;
padding: 0.75em 1.25em;
border: none;
border-radius: 0 4px 4px 0;
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion src/components/AutoAdvanceToggle/AutoAdvanceToggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
position: relative;
width: 60px;
height: 34px;
margin-left: 1rem;
margin-left: 1em;

input {
opacity: 0;
Expand Down
18 changes: 7 additions & 11 deletions src/components/MediaPlayer/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,15 @@ const MediaPlayer = ({
'videoJSCurrentTime',
'timeDivider',
'durationDisplay',
// These icons are in reverse order to support `float: inline-end` in CSS
'fullscreenToggle',
enableFileDownload ? 'videoJSFileDownload' : '',
enablePIP ? 'pictureInPictureToggle' : '',
enablePlaybackRate ? 'playbackRateMenuButton' : '',
'qualitySelector',
(hasStructure || playlist.isPlaylist) ? 'videoJSTrackScrubber' : '',
(playerConfig.tracks.length > 0 && isVideo) ? 'subsCapsButton' : '',
IS_MOBILE ? 'muteToggle' : 'volumePanel',
'qualitySelector',
enablePlaybackRate ? 'playbackRateMenuButton' : '',
enablePIP ? 'pictureInPictureToggle' : '',
enableFileDownload ? 'videoJSFileDownload' : '',
'fullscreenToggle'
IS_MOBILE ? 'muteToggle' : 'volumePanel'
// 'vjsYo', custom component
],
videoJSProgress: {
Expand Down Expand Up @@ -410,11 +411,6 @@ const MediaPlayer = ({
videoJSTitleLink: enableTitleLink
} : { sources: [] }; // Empty configurations for empty canvases

// Make the volume slider horizontal for audio in non-mobile browsers
if (!IS_MOBILE && !canvasIsEmpty) {
videoJsOptions.controlBar.volumePanel = { inline: isVideo ? false : true };
}

// Add file download to toolbar when it is enabled via props
if (enableFileDownload && !canvasIsEmpty) {
videoJsOptions.controlBar.videoJSFileDownload = {
Expand Down
44 changes: 22 additions & 22 deletions src/components/MediaPlayer/VideoJS/VideoJSPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IS_ANDROID, IS_IOS, IS_IPAD, IS_MOBILE, IS_SAFARI } from '@Services/bro
import { useLocalStorage } from '@Services/local-storage';
import { SectionButtonIcon } from '@Services/svg-icons';
import './VideoJSPlayer.scss';
import './videojs-theme.scss';

/** VideoJS custom components */
import VideoJSProgress from './components/js/VideoJSProgress';
Expand Down Expand Up @@ -372,6 +373,9 @@ function VideoJSPlayer({
const durationIndex = controlBar.children()
.findIndex((c) => c.name_ == 'DurationDisplay') ||
(hasMultipleCanvases ? 6 : 4);

const fullscreenIndex = controlBar.children()
.findIndex((c) => c.name_ == 'FullscreenToggle');
/*
Track-scrubber button: remove if the Manifest is not a playlist manifest
or the current Canvas doesn't have structure items. Or add back in if it's
Expand All @@ -383,14 +387,16 @@ function VideoJSPlayer({
// Add track-scrubber button after duration display if it is not available
controlBar.addChild(
'videoJSTrackScrubber',
{ trackScrubberRef, timeToolRef: scrubberTooltipRef },
durationIndex + 1
{ trackScrubberRef, timeToolRef: scrubberTooltipRef }
);
}

if (tracks?.length > 0 && isVideo && !controlBar.getChild('subsCapsButton')) {
const captionIndex = IS_MOBILE
? controlBar.children().findIndex((c) => c.name_ == 'MuteToggle')
: controlBar.children().findIndex((c) => c.name_ == 'VolumePanel');
let subsCapBtn = controlBar.addChild(
'subsCapsButton', {}, durationIndex + 1
'subsCapsButton', {}, captionIndex + 1
);
// Add CSS to mark captions-on
subsCapBtn.children_[0].addClass('captions-on');
Expand All @@ -414,30 +420,28 @@ function VideoJSPlayer({
}

/*
Volume panel display on desktop browsers:
For audio: volume panel is inline with a sticky volume slider
For video: volume panel is not inline.
Re-add volumePanel/muteToggle icon: ensures the correct order of controls
on player reload.
On mobile device browsers, the volume panel is replaced by muteToggle
for both audio and video.
*/
if (!IS_MOBILE) {
const volumeIndex = controlBar.children()
.findIndex((c) => c.name_ == 'VolumePanel');
controlBar.removeChild('volumePanel');
if (!isVideo) {
controlBar.addChild('volumePanel', { inline: true }, volumeIndex);
} else {
controlBar.addChild('volumePanel', { inline: false }, volumeIndex);
}
controlBar.removeChild('VolumePanel');
controlBar.addChild('VolumePanel');
/*
Trigger ready event to reset the volume slider in the refreshed
volume panel. This is needed on player reload, since volume slider
is set on either 'ready' or 'volumechange' events.
*/
player.trigger('volumechange');
} else {
controlBar.removeChild('MuteToggle');
controlBar.addChild('MuteToggle');
}

if (enableFileDownload) {
const fileDownloadIndex = controlBar.children()
.findIndex((c) => c.name_ == 'VideoJSFileDownload') || fullscreenIndex + 1;
controlBar.removeChild('videoJSFileDownload');

if (renderingFiles?.length > 0) {
Expand All @@ -446,13 +450,9 @@ function VideoJSPlayer({
controlText: 'Alternate resource download',
files: renderingFiles
};
// For video add icon before last icon, for audio add it to the end
isVideo
? controlBar.addChild('videoJSFileDownload', { ...fileOptions },
controlBar.children().length - 1
)
: controlBar.addChild('videoJSFileDownload', { ...fileOptions }
);
controlBar.addChild('videoJSFileDownload', { ...fileOptions },
fileDownloadIndex
);
}
}
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ function VideoJSPlayer({
data-testid={`videojs-${isVideo ? 'video' : 'audio'}-element`}
data-canvasindex={cIndexRef.current}
ref={videoJSRef}
className={`video-js vjs-big-play-centered vjs-disabled ${IS_ANDROID ? 'is-mobile' : ''}`}
className={`video-js vjs-big-play-centered vjs-theme-ramp vjs-disabled ${IS_ANDROID ? 'is-mobile' : ''}`}
onTouchStart={saveTouchStartCoords}
onTouchEnd={mobilePlayToggle}
style={{ display: `${canvasIsEmptyRef.current ? 'none' : ''}` }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class VideoJSFileDownload extends MenuButton {
constructor(player, options) {
super(player, options);
// Add SVG icon through CSS class
this.addClass("vjs-file-download-icon");
this.addClass("vjs-file-download");
this.setAttribute('data-testid', 'videojs-file-download');
// Use Video.js' stock SVG instead of setting it using CSS
this.setIcon('file-download');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class VideoJSNextButton extends vjsComponent {
constructor(player, options) {
super(player, options);
this.setAttribute('data-testid', 'videojs-next-button');
this.addClass('vjs-play-control vjs-control');

this.mount = this.mount.bind(this);
this.options = options;
Expand Down Expand Up @@ -92,7 +93,8 @@ function NextButton({
};

return (
<div className="vjs-button vjs-control">
<React.Fragment>
<span className="vjs-control-text" aria-live="polite">Next</span>
<button className="vjs-button vjs-next-button"
role="button"
ref={nextRef}
Expand All @@ -102,7 +104,7 @@ function NextButton({
onKeyDown={handleNextKeyDown}>
<SectionButtonIcon />
</button>
</div >
</React.Fragment >
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class VideoJSPreviousButton extends vjsComponent {
constructor(player, options) {
super(player, options);
this.setAttribute('data-testid', 'videojs-previous-button');
this.addClass('vjs-play-control vjs-control');

this.mount = this.mount.bind(this);
this.options = options;
Expand Down Expand Up @@ -94,7 +95,7 @@ function PreviousButton({
};

return (
<div className="vjs-button vjs-control">
<React.Fragment>
<button className="vjs-button vjs-previous-button"
role="button"
ref={previousRef}
Expand All @@ -104,7 +105,7 @@ function PreviousButton({
onKeyDown={handlePreviousKeyDown}>
<SectionButtonIcon flip={true} />
</button>
</div>
</React.Fragment>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class VideoJSTrackScrubber extends vjsComponent {
constructor(player, options) {
super(player, options);
this.setAttribute('data-testid', 'videojs-track-scrubber-button');
this.addClass('vjs-track-scrubber');

this.mount = this.mount.bind(this);
this.options = options;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import '../../../../../styles/vars';

.vjs-file-download-icon {
.vjs-file-download {
background-size: 1.25rem;
background-position: 0.75rem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

.video-js .vjs-custom-progress-bar {
cursor: pointer;
flex: auto;
display: flex;
align-items: center;
min-width: 4em;
touch-action: none;
height: 1em;
margin-top: 1.1em;
}

.vjs-progress-holder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vjs-previous-button,
.vjs-next-button {
cursor: pointer;
padding: 1.125em 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.vjs-track-scrubber-button {
cursor: pointer;
padding: 1.125em 0;
}

.vjs-track-scrubber-container {
Expand Down
Loading